Filtering in Pandas with ‘NaN’ and ‘isna’

When missing values are identified in Pandas, they are represented by a ‘NaN’ (Not a Number).

1, Checking for ‘NaN‘ Values

To identify ‘NaN’ values in your DataFrame, you can use the ‘isna()’ function. This function will return True if an element in an array is Not a Number (NaN)

The True values are those values that is ‘NaN’ (Not a Number).

Dropping ‘NaN’ Values

Drop Columns or Rows Only if all the Values are ‘NaN’ by Setting How Parameter

new_data = [‘name’:nan, ‘Age’:nan, ‘City’:nan]


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top