pandas where

DataFrame.where(cond, other=nan, inplace=False, axis=None, level=None, errors='raise', try_cast=False, raise_on_error=None)

Replace values where the condition is False.

替换数据集中不满足条件的值,默认替换为NaN,且不保存到数据集中。

输出的第一列是索引值。

 变量a没有改变:

添加第二个参数,表示把不符合条件的值改为此参数值

 

添加第三个参数,把更改保存到变量。

不添加inplace参数时有返回值:

添加inplace参数后没有返回值:

 

 

 

 

posted @ 2019-06-30 16:23  我的下铺刚田武  阅读(1259)  评论(0编辑  收藏  举报