day HIGH/LOW studies on 1-min S&P futures data. - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: day HIGH/LOW studies on 1-min S&P futures data. (/thread-27448.html) |
day HIGH/LOW studies on 1-min S&P futures data. - ptcm - Jun-07-2020 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. RE: day HIGH/LOW studies on 1-min S&P futures data. - scidam - Jun-07-2020 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) RE: day HIGH/LOW studies on 1-min S&P futures data. - ptcm - Jun-07-2020 (Jun-07-2020, 10:13 AM)scidam Wrote: What are column types (date and time)? 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? RE: day HIGH/LOW studies on 1-min S&P futures data. - ptcm - Jun-08-2020 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 ? |