Reputation: 417
I am trying to replace NAN from a dataframe column which is of float type.
> for i in range(len(tdf)):
> if tdf['Counterfeit_Weight'][i] =='NaN': # also have tried with np.NaN
> tdf.loc[i,"Counterfeit_Weight"]=p
I tried np.where, imputer class but nothing is working.
tdf.isnull().sum()
Medicine_ID 0
Counterfeit_Weight 1166
DistArea_ID 0
Active_Since 0
Plz Help
Upvotes: 0
Views: 983
Reputation: 739
Following one line should work for you
tdf['Counterfeit_Weight'].fillna(p)
Upvotes: 1