Search code examples
pandasseaborn

Pandas counting the null values and plotting in seaborn


I need to plot the count plot for a data set which has blank values.

I tried using

sns.countplot(x='ViolLevel',data=df1)

But this produces a plot:

enter image description here

which does not show the count of the null values (29740) in the data. (I find the number of null values using df1['ViolLevel'].isnull().sum())

How can I include the nan values in my count plot?


Solution

  • You can just replace the null values in your dataset with a string and run the plot again:

    df1.ViolLevel.fillna('Null', inplace=True)