I am doing Data-Wrangling in big data-set and there are many columns containing invalid values like Unspecified, 0 Unspecified and so on so, my goal is to replace them with NaN
value so that I can easily decide which column is useless or which are not by their ratio of total NaN
values respective total value rows. So, I am able to replace one value at a time and I want to do this all at a time as once
here is my code for replacing a value
for columns in cutmr_df.columns.values:
cutmr_df[columns] = cutmr_df.replace('Unspecified', np.nan)
I even have tried this too but I am getting error
for columns in cutmr_df.columns.values:
cutmr_df[columns] = cutmr_df.replace({columns: {'Unspecified': np.nan, '0 Unspecified': np.nan}})
#---------------------ERROR--------------------------#
Cannot compare types 'ndarray(dtype=int64)' and 'str'
So, How I should do this task