过滤其中nan出现在df列中的行

时间:2017-06-24 14:12:54

标签: python pandas

我有一个有很多行的df。

             Price   Time     Place
A             5.1    11.30   germany
B             4.1    08.30   lebannon
...
DY            7.49   01.15   italy  
DZ            2.13   02.35   england

如何过滤df以获取列Price具有Nan的行  值?

到目前为止,我试过

df[~df['Price'].str.isnumeric()]

但没有奏效。

所需的输出将是这样的:

             Price   Time     Place
AS            Nan    11.30   germany
BJ            Nan    08.30   lebannon

2 个答案:

答案 0 :(得分:1)

使用isnull

df[df.Price.isnull()]

您也可以使用np.isnan

df[np.isnan(df.Price.values)]

答案 1 :(得分:0)

尝试使用:

df = df.ix [df.price.isnull(),:]

df = df.loc [df.price.isnull(),:]

相关问题