Home > database >  Pandas drop all cells with Values and leave only blank cells
Pandas drop all cells with Values and leave only blank cells

Time:01-17

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?

CodePudding user response:

Assuming real NaNs:

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

If empty strings:

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

For both:

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