给定此数据框,如何仅选择“ Col2”等于的行NaN
?
In [56]: df = pd.DataFrame([range(3), [0, np.NaN, 0], [0, 0, np.NaN], range(3), range(3)], columns=["Col1", "Col2", "Col3"])
In [57]: df
Out[57]:
0 1 2
0 0 1 2
1 0 NaN 0
2 0 0 NaN
3 0 1 2
4 0 1 2
结果应该是这样的:
Out[57]:
0 1 2
1 0 NaN 0
df.loc[df['Col2'].isnull()]
如果.loc是您喜欢的东西