Plot timeline highlighting specific values present in DataFrame

Viewed 442

I have the following df :

df1 : 
index      Event1 Event2 Event3 Event4 Event5 Event6
2000-01-01    1     1      1      1      1       1
2000-01-02   nan   nan    nan    nan    nan     nan 
2000-01-03   nan   nan    nan    nan    nan     nan 
2000-01-04   nan   nan    nan    nan    nan     nan 
2000-01-05   nan   nan    nan    nan    nan     nan 
                            (...)
2000-02-03    1    nan      1    nan     1       1
2000-02-04   nan   nan    nan    nan    nan     nan 
2000-02-05   nan   nan    nan    nan    nan     nan 
2000-02-06   nan   nan    nan    nan    nan     nan 
2000-02-07   nan   nan    nan    nan    nan     nan 
                            (...)
2020-08-03   nan   nan    nan    nan    nan     nan
2020-08-05   nan   nan    nan    nan    nan     nan 
2020-08-07   nan   nan    nan    nan    nan     nan 
2020-08-10   nan    1     nan     1     nan     nan 
2020-08-13   nan   nan    nan    nan    nan     nan 

This df represents if certain event happened in the date assigned.

If there is an 1 as value in the first column of the df, the event1 happened in that date, and so on.

What I need is to plot this, like a timeline, showing when the events happened. I tried building a scatterplot, showing the values, but it was really off. Something like this would be nice : enter image description hereIf you guys could point me in any direction...

I looked up in the following links, but couldn't find a way of doing it:

  1. Seaborn timeseries plot with multiple series

  2. https://bbengfort.github.io/snippets/2016/01/29/timeline-visualization.html

  3. https://python-graph-gallery.com/seaborn/

Observations :

  1. the DataFrame itself is big, containing 20 years of Data. I believe I will not be able to plot in a single image with decent resolution, but I can break the DataFrame in smaller ones and then plot individually.
  2. I don't need every date to the in my y axis, but the gap can't be too wide as well.
  3. There is at least a month separating one event from another, in each column.
  4. Not necessarily, the events happened in the beginning of the month.
  5. The events happen in the same date, but some may not have happened.
1 Answers
Related