Home > other >  How to remove all those rows from a csv file that are empty of a specific column
How to remove all those rows from a csv file that are empty of a specific column

Time:10-26

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.

CodePudding user response:

Use dropna with the subset argument:

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

  • Related