I have a csv file with several variables.
Among the variables, Date and time is included separately.
Following image is the form of my data:
Date Time Axis1 Axis2 Axis3
. . . . .
. . . . .
2017-10-15 13:40:00 20 0 40
2017-10-15 13:40:10 40 10 100
2017-10-15 13:40:20 50 0 0
2017-10-15 13:40:30 10 10 60
2017-10-15 13:40:40 0 0 20
2017-10-15 13:40:50 0 0 10
2017-10-16 06:20:30 10 0 10
2017-10-16 06:20:40 70 0 10
2017-10-16 06:20:50 20 100 80
. . . . .
. . . . .
and there is more rows.(more than ten thousands)
You may notice that there is some time gaps between 10/15 and 10/16.
I'd like to sum all three Axis values by minute.
What I expect is this structure:
Date Time Axis1 Axis2 Axis3
. . . . .
. . . . .
2017-10-15 13:40:00 120 20 230
2017-10-16 06:20:00 100 100 100
2017-10-16 06:21:00 ? ? ?
. . . . .
. . . . .
I tried to use groupby, resample and pd.Grouper, But it does not work for me.
The main problem is that time index is not start from 13:40:00, but start from 00:00:00 after I put time as an index and use groupby('Date') and resample('1Min').sum().
Thanks for your help!
between_timeafterresampleoperation to filter out the time-range you don't want.df = df.between_time('06:20:00','13:40:00')