Binning/Grouping Dates on x-axis


I have a dataframe for a stacked bar and it looks something like:

I was wondering if there were any built-in features to support “binning” the date into weeks, months, years, etc. and summing the grouped values. I’ve done some workarounds to group by a generated “weekID” like 2021-32 using the datetime library, but the resulting plots have large x-axis gaps between years (202152 to 202201) and I’d much prefer to have the axis labeled something like (Jan 01, 21 - Jan 08, 21). Overall, the solutions I’ve come up with have been undesirably messy.

Is there anything in Plotly to do this easily, or will I need generate columns for sorting on my own?


Hello @Cashew

Maybe pivot table can help.