Created
May 18, 2020 05:40
-
-
Save Alakhator/3820b0f2f5fedba69f21f53bb4039448 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def missing_values_table(df): | |
mis_val = df.isnull().sum() | |
mis_val_percent = 100 * df.isnull().sum() / len(df) | |
mis_val_table = pd.concat([mis_val, mis_val_percent], axis=1) | |
mis_val_table_ren_columns = mis_val_table.rename( | |
columns = {0 : 'Missing Values', 1 : '% of Total Values'}) | |
mis_val_table_ren_columns = mis_val_table_ren_columns[ | |
mis_val_table_ren_columns.iloc[:,1] != 0].sort_values( | |
'% of Total Values', ascending=False).round(1) | |
print ("Your selected dataframe has " + str(df.shape[1]) + " columns.\n" | |
"There are " + str(mis_val_table_ren_columns.shape[0]) + | |
" columns that have missing values.") | |
return mis_val_table_ren_columns | |
missing_values_tables(train+test) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment