首页 > 解决方案 > 选择 Col1 "isnull" & Col2 "notnull" 的行

问题描述

我想选择 col1 中的值为 null 并且 col2 中的值不为 null 的行

col1  col2
423   NaN
NaN   291
391   102

期望的输出

col1 col2
NaN  291

标签: pythonpandas

解决方案


使用pandas loc

df.loc[(df['col1'].isna()) & (~df['col2'].isna())]

推荐阅读