I would like to know if there's a way to pad empty dates rows when doing a pivot table when there're not present in the source table.

More context about what I'm trying to do. I track workout data and its duration. I have different activities. I want to make an aggregate weekly summary visualized with a stacked bar chart.

date        week        activity        duration (min)  duration (hours)
26/05/2023  22/05/2023  strengthening   60              1:00:00
28/05/2023  22/05/2023  climbing        90              1:30:00
29/05/2023  29/05/2023  strengthening   13              0:13:00
30/05/2023  29/05/2023  climbing        120             2:00:00

After every workout, I add the date, the duration and the activity. The first day of the week and the duration in hours in calculated.

I then do a pivot table. enter image description here

Then plot it.

enter image description here

In this case, there is no data between the 17/07/2023 and 31/07/023 and this week doesn't appear in the graph. I would like the week date to appear, with a zero value.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.