A B C D E F
0 1.0 2013-01-02 1.0 3 test foo
1 1.0 2013-01-02 1.0 3 train foo
2 1.0 2013-01-02 1.0 3 test foo
3 1.0 2013-01-02 1.0 3 train foo将第0行 第A列的值改成NaN
df.loc[0,'A'] = np.NaN A B C D E F
0 NaN 2013-01-02 1.0 3 test foo
1 1.0 2013-01-02 1.0 3 train foo
2 1.0 2013-01-02 1.0 3 test foo
3 1.0 2013-01-02 1.0 3 train foo将空值补全 假设补为2
df.loc[(df.A.isnull())], 'A'] = 2 A B C D E F
0 2.0 2013-01-02 1.0 3 test foo
1 1.0 2013-01-02 1.0 3 train foo
2 1.0 2013-01-02 1.0 3 test foo
3 1.0 2013-01-02 1.0 3 train foo
本文介绍了一种数据处理的方法,包括如何使用Python Pandas库中的loc函数修改DataFrame中特定单元格的值,例如将其设置为NaN,以及如何填充这些缺失值。
7619

被折叠的 条评论
为什么被折叠?



