JamesHudson81
JamesHudson81

Reputation: 2273

filter rows where nan appear in a df column

I have a df with lots of rows.

             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

How could I filter the df to obtain those rows where column Price has a Nan value?

So far I tried

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

but didn't worked.

The desired output would be something like this:

             Price   Time     Place
AS            Nan    11.30   germany
BJ            Nan    08.30   lebannon

Upvotes: 1

Views: 451

Answers (2)

Logical Retard
Logical Retard

Reputation: 143

Try using this :

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

or

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

Upvotes: 0

piRSquared
piRSquared

Reputation: 294258

use isnull

df[df.Price.isnull()]

You can also use np.isnan

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

Upvotes: 1

Related Questions