I would like to exclude ratings column and correctYear column from getting categorized. I would like to categorize every other object type field but leave out these two because they are numeric values.
name object
rating object
genre object
year int64
released object
score float64
votes float64
director object
writer object
star object
country object
budget float64
gross float64
company object
runtime float64
correctYear object
dtype: object
below is my code
tried type casting correctYear but got this error
could not convert string to float:
df_cat = df
for col in df_cat.columns:
if (df_cat[col].dtype=='object' & (df_cat[col]!='rating' | df_cat[col]!='correctYear')):
df_cat[col] = df_cat[col].astype('category')
df_cat[col] = df_cat[col].cat.codes
Any help would be greatly appreciated :)