简体   繁体   English

如何用两个值的总和在特定列中填充 NA?

[英]How do I fill NA in specific column with the sum of two values?

I want to impute missing values I have in a 'Roll_time' column.我想估算我在“Roll_time”列中的缺失值。 I created a 'Time_diff' column that has the difference between 'Roll_time' and 'Notif_time' for the rows that have all the data.我为包含所有数据的行创建了一个“Time_diff”列,该列具有“Roll_time”和“Notif_time”之间的差异。

I'm trying to use the sum of the mean 'Time_diff' and the respective 'Notif_time' for the row to impute into the missing 'Roll_time' values.我正在尝试使用该行的平均“Time_diff”和相应的“Notif_time”之和来估算缺失的“Roll_time”值。

how about this这个怎么样

df['Roll_time'].fillna(df['Time_diff'].mean() + df['Notif_time'])   

# df['Time_diff'] = (df['Roll_time'] - df['Notif_time']).fillna(0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM