Sameer Khan
Sameer Khan

Reputation: 27

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

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.

Upvotes: 0

Views: 393

Answers (1)

Sheldon
Sheldon

Reputation: 4633

Use dropna with the subset argument:

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

Upvotes: 2

Related Questions