python: assign time bins to rows using timestamp column

Viewed 1036

I have a dataset with some numeric observations with a start and end time for it. I am trying to assign a bin to each observation, each bin is 5 minutes, which should be assigned if the transaction started in that interval. (I explored resampling option in pandas but there I couldn't find a way to retain unique attributes of observation, amount for example)

data
id     start               end                 amt count
1004 2017-07-01 08:02:30 2017-07-01 10:02:30 250   1
1004 2017-07-01 08:09:30 2017-07-01 09:03:35 250   1
1006 2017-07-01 09:54:50 2017-07-01 10:26:31 50    1

timebins
0 00:00:00
1 00:05:00
2 00:10:00

desired output would be,

id       start           end                 amt count    bin 
1004 2017-07-01 08:02:30 2017-07-01 10:02:30 250   1      08:00
2 Answers
Related