Python Forum
Show empty categories in catplot with boxplots - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Show empty categories in catplot with boxplots (/thread-36119.html)



Show empty categories in catplot with boxplots - PBRM - Jan-18-2022

I have a dataframe like:

ID * Period * value-system
1 * 2021-11 * 1010
2 * 2021-11 * 0
3 * 2021-11 * 988
4 * 2021-11 * 1023
5 * 2021-11 * 0
6 * 2021-12 * 0
7 * 2021-12 * 0
etc.

To create the boxplot I need (with sn catplot), I filtered the dataframe by leaving out all the rows with 0 for value-system. The result is shown in the following plot[attachment=1528].
Now, in the plot several periods are missing (2021-05 through 2021-08). These periods are present in the dataframe, but contain only 0-values, so left out by the filter. Now I want to show these 'missing' periods. With periods = df["Period"].unique() I can get all the periods I need, but how can I show these empty periods in the plot?

Hints are appreciated!