~/blog/Find-Missing-Data-Percentage
Published on

Missing Data Percentage and Count in pandas

172 words1 min read–––
Views
Authors

I use this piece of code practically daily. So, thought it could be a nice idea to share.

df⁣ — Is the input dataset with missing values

missing number—This is the total of the missing values in the data frame.

missing percent—This indicates the proportion of missing values in the data frame.

Use the below code to display the missing statistics.

missing_number  =  df.isnull().sum()
missing_percent  =  df.isnull().sum() *  100  /  len(df)
missing_value_df  =  pd.DataFrame({'column_name': df.columns,

'missing_count': missing_number,

'percent_missing': missing_percent})
missing_value_df  =  missing_value_df.reset_index(drop=True)
missing_value_df.sort_values('percent_missing')