I have df with features in my google colab, and suddenly appeared error:
Code:
df_features['cooling'] = df['cooling'].astype('object')
df_features['view'] = df['view'].astype('object')
cat_features = ['cooling', 'view', 'city_region']
X = df_features.drop('target', axis=1)
y = df_features['target']
num_cols = [col for col in X.columns if X[col].dtype in ['float64','int64']]
cat_cols = [col for col in X.columns if X[col].dtype not in ['float64','int64']]
Here is error: --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) in () 5 y = df_features['target'] 6 ----> 7 num_cols = [col for col in X.columns if X[col].dtype in ['float64','int64']] 8 cat_cols = [col for col in X.columns if X[col].dtype not in ['float64','int64']] 9
1 frames
/usr/local/lib/python3.7/dist-packages/pandas/core/generic.py in __getattr__(self, name)
5485 ):
5486 return self[name]
-> 5487 return object.__getattribute__(self, name)
5488
5489 def __setattr__(self, name: str, value) -> None:
AttributeError: 'DataFrame' object has no attribute 'dtype'
I already tried to use !pip install --upgrade pandas but it had no success