[英]Pandas Apply function on Column
I have a few columns in the Pandas dataframe which are sparsely populated, and I wish to modify their respective values to, whether they are filled or not. 我在Pandas数据框中有几列是稀疏填充的,我希望将其各自的值修改为是否填充。
For instance, my dataframe is: 例如,我的数据框是:
A B C D
0 8 8
1 9 4 4
2 5 3 8
3 4 1
I want it to be : 我希望它是:
A B C D
0 8 F F 8
1 9 T F 4
2 5 F T 8
3 4 F F 1
F = False, T= True F = False,T = True
Running pandas.isnull(df['B'])
returns a new series with boolean values, how do I update it efficiently in the original dataframe? 运行
pandas.isnull(df['B'])
返回具有布尔值的新系列,如何在原始数据帧中有效地对其进行更新?
您可以执行df['B'] = df.B.notnull()
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.