Menu Close

How to drop rows of a Python Pandas DataFrame whose value in a certain column is NaN?

To drop rows of a Python Pandas DataFrame whose value in a certain column is NaN, we call the notna method.

For instance, we write

df = df[df['EPS'].notna()]

to filter out the rows with 'EPS' column value that’s NaN by calling thw notna method on the column.

Then we get the filtered rows with df[df['EPS'].notna()]

Posted in Python, Python Answers