Pandas drop all cells with Values and leave only blank cells

Advertisements

I want to do the following:

index A1
0 1
1
2 -8
3 Hello
4

to:

index A1
1
4

Is there like a reverse .dropna function?

>Solution :

Assuming real NaNs:

out = df[df['A1'].isna()]

If empty strings:

out = df[df['A1'].eq('')]

For both:

out = df[df['A1'].fillna('').eq('')]

Leave a Reply Cancel reply