有条件地更改pandas df中的列值

时间:2016-11-29 12:45:51

标签: python pandas

我在pandas df中有一张桌子。

id   count
1      1
2      5
3      7
4      9
5      NaN
6      NaN

我希望将计数更改为1,只要计数为Nan

df['count'] = 1

这会使所有列都为1,但我不想要那个,有没有办法来定义pandas df中的条件

0 个答案:

没有答案
相关问题