简体   繁体   English

在 dataframe 中标记包含任意列 = NAN 的行

[英]Mark row in dataframe that contains a any column = NAN

I have a dataframe that contains 3 columns我有一个包含 3 列的 dataframe

Some rows contain a column that has a NaN Value.某些行包含具有 NaN 值的列。

I have used checkfornan=df.isnull() to generate a dataframe (checkfornan) that I can used to locate individual values a NaN.我使用checkfornan=df.isnull()生成了一个 dataframe (checkfornan),我可以用它来定位单个值 NaN。

But what I would like to do is add another column in my original dataframe (df) say 'isNaN' and assign a value of True into that column if any other value in the same row is Nan, or False if no values in same column are NaN.但是我想做的是在我的原始 dataframe (df) 中添加另一列,说“isNaN”,如果同一行中的任何其他值为 Nan,则为该列分配 True 值,如果同一列中没有值,则为 False是 NaN。

Being new to Dataframe, I am not sure how I use the output from df.isnull() dataframe to combine it with my original dataframe to achieve this? Being new to Dataframe, I am not sure how I use the output from df.isnull() dataframe to combine it with my original dataframe to achieve this?

Any ideas?有任何想法吗?

thanks谢谢

Check if any column is a NaN, create a new column:检查是否有任何列是 NaN,创建一个新列:

df['isNaN'] = df.isnull().any(axis=1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM