2
[OK]をので、私はpandas pivot table documentationを見て、以下同様の質問している:私の問題は、出力timedeltas
たときに集約されるしかしフォーマット集計はtimedelta
彼らは1 day 12:30:00
のフォーマットを表示して、それを36:30:00
と表示したいとします。これを行う方法はありますか?
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
そう簡単ではない
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
私は 'applymap'オプションと一緒に行きました。 –