Reputation: 391
I'm trying to filter a Pandas data frame based on a criteria (Python 2.7):
data[data['a']=='bbb']
But some of the values in the series data['a'] are NaN and I get an error:
invalid type comparison
.
How can I ignore it and treat the NaN as not matching the criteria thus filtering it out?
Thanks!!
Upvotes: 2
Views: 617
Reputation: 32
Reassign the column type as follows:
df['a'] = df['a'].astype('O')
This should solve the issue.
Upvotes: 2