Skip to content
Advertisement

Time Series Plot Seaborn with MultiIndex

I have the following dataset:

                     Count
Submit date   Code
2019-09-01    1      24 
2019-09-01    2      29
2019-09-01    3      11
2019-09-01    4      55 
2019-09-01    5      NaN
2019-09-02    1      9
2019-09-02    2      19
2019-09-02    3      NaN
2019-09-02    4      71 
2019-09-02    5      8 
2019-09-03    1      5 
...

The dataset spans three months and counts the occurrence of five codes per day.

In order to plot the data I have just used the following code:

groupeddataset['Count'].unstack().fillna(0).plot(figsize=(60,20),lw = 3, marker = "o", ms = 3)

I am wondering though, how this can be done using seaborn and a lineplot ?

Advertisement

Answer

Is this what you are looking for?

sns.lineplot(x='Submit date', y='Count', style='Code', data=groupeddataset.reset_index())
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement