Created
December 28, 2020 18:10
-
-
Save redpoint13/51a97653ac152d3d80e92f289b601b2a to your computer and use it in GitHub Desktop.
missing value heatmap from pandas dataframe
This file contains hidden or 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
import seaborn as sns | |
cols = df.columns[:30] # first 30 columns | |
colors = ['#000099', '#ffff00'] # specify the colours - yellow is missing. blue is not missing. | |
sns.heatmap(df[cols].isnull(), cmap=sns.color_palette(colors)) | |
# if it's a larger dataset and the visualization takes too long can do this. | |
# % of missing. | |
for col in df.columns: | |
pct_missing = np.mean(df[col].isnull()) | |
if pct_missing > 0.009: | |
print('{} - {}%'.format(col, round(pct_missing*100))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment