Skip to content

Instantly share code, notes, and snippets.

Last active Jun 23, 2019
What would you like to do?
A function to plot percentage of nulls in a dataframe (using seaborn and matplotlib)
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)
_ = 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