Problems using iloc pandas

Asked

Viewed 31 times

0

I want to create a new DataFrame with the following condition:

marvel.loc[ marvel['Orientation'] != 'NaN' ]

I mean, I want every line that has the column 'Orientation'== 'NaN' are deleted, but there is something going wrong. Follow the code:

marvel= pd.read_csv('Heroes_Marvel.csv')
marvel.count()
print(marvel.isna().sum())
marvel.columns
orientation=  marvel.loc[(marvel['Orientation']!='NaN')]

and when I put to print the Orientation is everything including the NaN's

1 answer

-1


Because of the way NaN's are defined NaN == NaN -> False. You must use the function pd.IsNull

Browser other questions tagged

You are not signed in. Login or sign up in order to post.