Pandas - Filtering No Values

I use Pandas to learn some datasets. I have this framework:

enter image description here

I want to exclude any string that matters the city. So I tried:

new_df = all_df[(all_df["City"] == "None") ]
new_df

But then I got an empty framework:

enter image description here

It works whenever I use any value other than None. Any idea how to filter this framework?

+4
source share
3 answers

Consider using isnull()to determine missing values.

all_df[all_df['City'].isnull()]
+11
source

I hope that " where" can do what you expect

new_df = new_df.where(new_df["city"], None) 

And better to use np.nanthan None.

pandas.DataFrame.where

+2

None :

new_df = all_df['City'][all_df['City'] == "None"]

Try this to see all other columns that have the same row. 'City'==None

new_df = all_df[all_df['City'] == "None"]
print(new_df.head()) # with function head() you can see the first 5 rows
+2
source

Source: https://habr.com/ru/post/1681507/


All Articles