[英]How to replace Nan from column with float data in a data frame in python
I am trying to replace NAN from a dataframe column which is of float type. 我正在尝试从浮点类型的数据框列中替换NAN。
> 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. 我尝试了np.where,不完美的课程,但是没有任何反应。
tdf.isnull().sum()
Medicine_ID 0
Counterfeit_Weight 1166
DistArea_ID 0
Active_Since 0
Plz Help 请帮助
跟随一行就可以为您工作
tdf['Counterfeit_Weight'].fillna(p)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.