【发布时间】:2023-04-02 23:20:01
【问题描述】:
我想用 0 替换 F1[id1] 中的 Value Nan 。否则F1[id1] = 1
代码:
它不起作用。请问我该如何解决
F1.id1 = [0 if pd.isna(e) else 1 for e in F1.id1]
Here the output ofF1
【问题讨论】:
标签: python pandas if-statement
我想用 0 替换 F1[id1] 中的 Value Nan 。否则F1[id1] = 1
代码:
它不起作用。请问我该如何解决
F1.id1 = [0 if pd.isna(e) else 1 for e in F1.id1]
Here the output ofF1
【问题讨论】:
标签: python pandas if-statement
使用fillna():
F1.fillna(0, inplace=True)
【讨论】: