I have created a data frame with 3 columns, the third one contains lists, I want to drop rows that contains an empty list in that cell.
I have tried with
df[df.numbers == []] and df[df.numbers == null]
but nothing works.
name country numbers
Lewis Spain [1,4,6]
Nora UK []
Andrew UK [3,5]
The result will be a data frame without Nora's row
Drop Empty Rows or Columns If you're looking to drop rows (or columns) containing empty data, you're in luck: Pandas' dropna() method is specifically for this.
To drop all the rows which contain only missing values, pass the value 0 to the axis parameter and set the value how='all' .
To drop all the rows with the NaN values, you may use df. dropna().
Umm check bool
df[df.numbers.astype(bool)]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With