I have a CSV file attached below, I need to split the time for 1 day into 4 intervals, i.e: 9:15-10:00, 10:01-12:00, 12:01-14:30 & 14:31-15:30 and get the values of 'Open' as the first value in every interval, 'High' as the max value, 'low' as the lowest, 'close' as the last value of the interval and 'volume' as the sum of all volume values in an interval. This same procedure is to be done for everyday. I have tried using group by function for specific intervals but it gives the values for whole csv file. I have also tried resampling but it doesn't work for me. Here is the code which I tried.
ohlc_dict = {
'Open':'first',
'High':'max',
'Low':'min',
'Close':'last',
'Volume':'sum'
}
df = df.resample('60min').agg(ohlc_dict)
And one more:
df = df.groupby(pd.Grouper(freq='60Min',closed='right',label='right')).agg({
"Open": "first",
"High": "max",
"Low": "min",
"Close": "last",
"Volume": "sum"
})