Check the values of train_new. You'll see that the columns mentionned are not of the expected types.
Another suggestion, i'm not sure of xgboost's handling of nulls. Might be that in those columns aswell.
Answer from Wizard_10101010 on Stack ExchangeCheck the values of train_new. You'll see that the columns mentionned are not of the expected types.
Another suggestion, i'm not sure of xgboost's handling of nulls. Might be that in those columns aswell.
Perform Label encoding for the features like Alley, Condition2, etc (mentioned in your error). For example:
train_new['Electrical'] = le.fit_transform(train_new['Electrical'].astype(str))
The above is the snippet for your reference. Do not apply .astype(str) for Condition2 only. Excluding that u need to apply the line that I gave u for all attributes (mentioned in error). I hope this solves your error.
AnnData Operations - AttributeError: 'DataFrame' object has no attribute 'dtype'
pandas - AttributeError: 'DataFrame' object has no attribute 'dtype' appeared suddenly - Stack Overflow
AttributeError: 'DataFrame' object has no attribute 'dtype'
'DataFrame' object has no attribute 'dtype'
df[col] will return a DataFrame object (not a Series) if df contains more than one column with the same name. Make sure you do not have more than one column with the same name in df as that is the likely source of this error.
You seem to somehow get back a DataFrame and not a Series by calling X[col]. Not sure why, because you did not supply the full structure and data of your dataframe.
.dtype is for pandas Series https://pandas.pydata.org/docs/reference/api/pandas.Series.dtype.html
.dtypes is for pandas Dataframes (and seems also to work with pandas Series) https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.dtypes.html
This works for me on the current version of pandas:
pd.to_datetime(df)
0 2015-02-04
1 2016-03-05
dtype: datetime64[ns]
Pandas to_datetime has special support to parse a datetime column from a supplied DataFrame input iff it contains specifically "year", "month" and "day" columns (order doesn't matter, and case sensitivity doesn't either).
It's likely you're working with a much older version of pandas in which case I'd recommend an upgrade!
However...
If upgrading isn't an option, you can always join the columns and call to_datetime on the Series.
Try joining the columns and then applying pd.to_datetime.
pd.to_datetime(df[['year', 'month', 'day']].astype(str).apply('-'.join, 1))
0 2015-02-04
1 2016-03-05
dtype: datetime64[ns]
DataFrame.dtypes is an attribute to list data types, for series it's a dtype.
reference: https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.dtypes.html
wine = pd.read_csv("combined.csv", header=0).iloc[:-1]
df = pd.DataFrame(wine)
df
dataset = pd.DataFrame(df.data, columns =df.feature_names)
dataset['target']=df.target
datasetERROR:
<ipython-input-27-64122078da92> in <module>
----> 1 dataset = pd.DataFrame(df.data, columns =df.feature_names)
2 dataset['target']=df.target
3 dataset
D:\Anaconda\lib\site-packages\pandas\core\generic.py in __getattr__(self, name)
5463 if self._info_axis._can_hold_identifiers_and_holds_name(name):
5464 return self[name]
-> 5465 return object.__getattribute__(self, name)
5466
5467 def __setattr__(self, name: str, value) -> None:
AttributeError: 'DataFrame' object has no attribute 'data'I'm trying to set up a target to proceed with my Multi Linear Regression Project, but I can't even do that. I've already downloaded the CSV file and have it uploaded on a Jupyter Notebook. What I'm I doing wrong?