I have a pandas dataframe (stored in a .csv file) with the following format.
val,date,time
0.001,01JAN90,0:00:00
0.002,01JAN90,0:01:00
0.005,01JAN90,0:02:00
0.056,01JAN90,0:03:00
...
0.067,31DEC90,23:55:00
0.007,31DEC90,23:56:00
0.006,31DEC90,23:57:00
0.004,31DEC90,23:58:00
0.003,31DEC90,23:59:00
This is: a single float (val column) for each minute (time column) of each day (time column) in a year. I need to group the val elements throughout the entire year, that belong to a given hour range. I define 15 hour ranges as:
t_range = [['5:30:00', '6:30:00'], ['6:30:00', '7:30:00'], ...,
['19:30:00', '20:30:00']]
The answer given here Pandas Groupby Range of Values deals with ranges defined as floats, but my ranges are defined as strings.
My idea is that I'd need to first convert all the HH:MM:SS values in time to floats, and then apply the solution based on groupby and pd.cut. Is this the proper approach? How should I be using pandas to do this if not?