Last active
June 23, 2019 18:31
-
-
Save ricgu8086/e30360e44e5c0dd54d28256424eb9f91 to your computer and use it in GitHub Desktop.
A function to plot percentage of nulls in a dataframe (using seaborn and matplotlib)
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 plot_nulls(dataframe): | |
def null_perc(dataframe): | |
return 100*dataframe.isnull().sum()/len(dataframe) | |
nulls = null_perc(dataframe) | |
plt.figure(1, figsize=(5,20)) # Customize this if needed | |
ax = sns.barplot(x=nulls, y=list(range(len(nulls))), orient='h', color="blue") | |
_ = plt.yticks(plt.yticks()[0], nulls.index) | |
ax.xaxis.set_ticks_position('top') | |
_ = plt.title("Null percentage (lower is better)", fontsize=15, pad=30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment