简体   繁体   English

如何在Python的数据框中使用浮点数据替换列中的Nan

[英]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.

相关问题 如何替换熊猫数据框中列中的 NaN 值? - how to replace a NaN value in a column in data frame in pandas? 如果列名称为nan,如何从数据框中删除整列,Python 3.6 - How to remove entire column from data frame if column name is nan, Python 3.6 如何用 python 中其他数据帧的条目替换一个数据帧中缺少的列条目? - How to replace missing entries of a column in one data frame with entries from other data frame in python? 用另一列中的元素替换数据框中的列-python - replace column in data frame with elements from another column - python 如何在 Python 中的数据框中填充类型为 Float 的列的模式值 - How to fillna with mode value of a Column with type Float in a data frame in Python 用列表中的唯一值替换数据框中列中的 NAN 值? - Replace NAN values in a column from a data frame by unique values from a list? 用Python中的nan替换浮点列中的点 - Replace dots in a float column with nan in Python 我应该如何使用另一列将值按比例替换为数据框中的“NaN”值? - How should I replace values proportionally to 'NaN' values in a data frame by using another column? 将数据框中的列从 float 截断为 int - Truncate column in data frame from float to int 从数据框列中删除一个字符串短语并替换为python - Delete a string phrase from a data frame column and replace it python
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM