Ok so I have looked at the pandas pivot table documentation and the following similar questions:
However my issue is the outputted timedeltas
when aggregated they show the format 1 day 12:30:00
when I want it to display 36:30:00
. Is there a way to do this?
CODE
pd.pivot_table(
df,
index=["date","task_type"],
columns=["calendar"],
values="duration",
aggfunc=np.sum,
fill_value=timedelta(hours=0),
margins=True,
margins_name="TOTAL"
)
OUTPUT
calendar Proj1 Proj2 Proj3 TOTAL
date task_type
2017-05-04 01:00:00 00:00:00 0 days 00:00:00 0 days 01:00:00
development 00:00:00 00:00:00 0 days 02:00:00 0 days 02:00:00
training 00:00:00 00:00:00 0 days 04:00:00 0 days 04:00:00
2017-05-05 admin 00:00:00 02:00:00 0 days 00:00:00 0 days 02:00:00
development 00:30:00 00:00:00 0 days 03:30:00 0 days 04:00:00
meeting 00:00:00 00:00:00 0 days 01:00:00 0 days 01:00:00
2017-05-08 01:30:00 00:00:00 0 days 00:00:00 0 days 01:30:00
admin 00:00:00 02:00:00 0 days 00:00:00 0 days 02:00:00
development 00:00:00 00:00:00 0 days 05:00:00 0 days 05:00:00
2017-05-09 admin 02:00:00 01:00:00 0 days 00:00:00 0 days 03:00:00
development 00:00:00 00:00:00 0 days 01:00:00 0 days 01:00:00
research 01:00:00 00:00:00 0 days 00:00:00 0 days 01:00:00
training 00:00:00 00:00:00 0 days 03:30:00 0 days 03:30:00
2017-05-10 admin 00:00:00 01:30:00 0 days 00:00:00 0 days 01:30:00
development 00:00:00 00:00:00 0 days 02:30:00 0 days 02:30:00
meeting 02:00:00 00:00:00 0 days 00:00:00 0 days 02:00:00
training 00:00:00 00:00:00 0 days 02:00:00 0 days 02:00:00
2017-05-11 admin 00:00:00 01:00:00 0 days 00:00:00 0 days 01:00:00
development 00:00:00 02:30:00 0 days 00:00:00 0 days 02:30:00
TOTAL 08:00:00 10:00:00 1 days 00:30:00 1 days 18:30:00
EXPECTED
calendar Proj1 Proj2 Proj3 TOTAL
date task_type
2017-05-04 01:00:00 00:00:00 00:00:00 01:00:00
development 00:00:00 00:00:00 02:00:00 02:00:00
training 00:00:00 00:00:00 04:00:00 04:00:00
2017-05-05 admin 00:00:00 02:00:00 00:00:00 02:00:00
development 00:30:00 00:00:00 03:30:00 04:00:00
meeting 00:00:00 00:00:00 01:00:00 01:00:00
2017-05-08 01:30:00 00:00:00 00:00:00 01:30:00
admin 00:00:00 02:00:00 00:00:00 02:00:00
development 00:00:00 00:00:00 05:00:00 05:00:00
2017-05-09 admin 02:00:00 01:00:00 00:00:00 03:00:00
development 00:00:00 00:00:00 01:00:00 01:00:00
research 01:00:00 00:00:00 00:00:00 01:00:00
training 00:00:00 00:00:00 03:30:00 03:30:00
2017-05-10 admin 00:00:00 01:30:00 00:00:00 01:30:00
development 00:00:00 00:00:00 02:30:00 02:30:00
meeting 02:00:00 00:00:00 00:00:00 02:00:00
training 00:00:00 00:00:00 02:00:00 02:00:00
2017-05-11 admin 00:00:00 01:00:00 00:00:00 01:00:00
development 00:00:00 02:30:00 00:00:00 02:30:00
TOTAL 08:00:00 10:00:00 24:30:00 42:30:00