I would like to do the sum of the column duration group by date but the column begin and end are datetime in this piece of df:
begin end duration
2020-10-14 19:17:52.724020 2020-10-14 19:21:40.179003 227.45
2020-10-14 19:21:40.179003 2020-10-14 19:21:44.037103 3.86
2020-10-14 19:59:27.183161 2020-10-14 20:00:43.847816 76.66
2020-10-14 20:00:43.847816 2020-10-14 20:00:43.847822 0
2020-10-14 20:02:14.341240 2020-10-14 23:59:59.900000 14265.56
2020-10-15 00:00:00.000000 2020-10-15 05:25:32.935971 19532.94
2020-10-15 05:25:32.935971 2020-10-15 05:25:33.068959 0.13
df.info()
begin 41763 non-null datetime64[ns]
end 41763 non-null datetime64[ns]
duration 41763 non-null float64
The result must be:
begin duration
2020-10-14 14,573.53
2020-10-15 19,533.07
So I tried on my all df, this but its works for certain date and no for other. Because I do the same with excel and for a date I have a different result.
import pandas as pd
import datetime
df = df.groupby(df['begin_'].dt.date)['duration_'].sum()/3600
this but its works for certain date and no for other.- Can you add some rows with not working?