0

Example CSV file

In the following csv I want to remove all rows that are empty with respect to column 'Age' only (i.e. row 4 & 5 to be removed of entire file)

I tried

df['Age'].dropna(how ='any')

But this isn't the solution.

  • [How to make good reproducible pandas examples](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples). [Why should I not upload images of ... when asking a question?](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors-when-asking-a-question). – wwii Oct 19 '22 at 18:37
  • 1
    Does - [Drop rows containing empty cells from a pandas DataFrame](https://stackoverflow.com/questions/29314033/drop-rows-containing-empty-cells-from-a-pandas-dataframe) - answer your question? – wwii Oct 19 '22 at 18:39
  • [how to remove a row which has empty column in a dataframe using pandas](https://stackoverflow.com/questions/51374068/how-to-remove-a-row-which-has-empty-column-in-a-dataframe-using-pandas) – wwii Oct 19 '22 at 18:42

1 Answers1

2

Use dropna with the subset argument:

df.dropna(subset=['Age'], how='any')

Sheldon
  • 4,084
  • 3
  • 20
  • 41