Dharm paaji
Dharm paaji

Reputation: 44

why I Can't drop NAN values with dropna() function in pandas

simple i make pandas data frame from dictionary then use dropna I dont know why its not removing NaN

df=pd.DataFrame(dic)
df.dropna(axis=1,inplace=True)
df.head()

Image of Output with code

my code link(not completed) https://colab.research.google.com/drive/1HoniG14dUZbERxDm9QKowjkpacK3wyt5?usp=sharing

Upvotes: 0

Views: 3242

Answers (1)

mozway
mozway

Reputation: 260570

You likely have "NaN" strings. You should first convert them to real NA values. Let's use pd.NA:

df = df.replace('NaN', pd.NA).dropna(axis=1)

Upvotes: 4

Related Questions