I am trying to do a day HIGH/LOW studies on 1-min S&P futures data.
I have 2 questions.
1) How could I print the day HIGH / LOW for each day
2) How could I print the day HIGH / LOW for the first hour of trading
Thanks a lot in advance.
![[Image: 49979016508_ac2c704a2f_c.jpg]](https://cdn.bmcharts.com/postcache/4/b/0/6/9/f/49979016508_ac2c704a2f_c.jpg)
What are column types (date and time)?
If they are of DateTime dtype (datetime64[ns]), you can do this using groupby, e.g.
df.groupby('date')['high'].max() # get max values of 'high' column for each day
df.groupby('date')['high'].min() # get min values of 'high' column for each day
df.groupby([df.date, df.time.dt.hour])['high'].max() # get max values of 'high' column for each hour (during the day)
(Jun-07-2020, 10:13 AM)scidam Wrote: [ -> ]What are column types (date and time)?
If they are of DateTime dtype (datetime64[ns]), you can do this using groupby, e.g.
df.groupby('date')['high'].max() # get max values of 'high' column for each day
df.groupby('date')['high'].min() # get min values of 'high' column for each day
df.groupby([df.date, df.time.dt.hour])['high'].max() # get max values of 'high' column for each hour (during the day)
Thanks scidam for your quick reply.
I am kind of stuck here. I want to have the output displayed all in 2 lines day by day like the following.
Date, Time, High
Date, Time, Low
How could I write it in such a way to achieve that ? many thanks. I went thru many Youtube videos on groupby, but I am not able to find groupby with multiple columns outputs with different calculation criteria(Max of High and Min of Low in this case.)
data type originally
Then I converted the Date and Time to datetime64 format. Not sure if I made it better or worse?
![[Image: 49980598277_9b1e927e59_c.jpg]](https://live.staticflickr.com/65535/49980598277_9b1e927e59_c.jpg)
I need to print the day HIGH / LOW for each day and the time it occurred. I can't find a way to retrieve the corresponding time using the groupby function.
Can someone please help ?