2021年3月12日星期五

Python Pandas: Compare ticks with differing intervals to hourly data

I have a months worth of ticks at differing intervals in a pandas dataframe as follows

                         Spread  Date                             2021-02-01 00:01:10.718     9.0  2021-02-01 00:01:14.471     9.2  2021-02-01 00:01:24.794     5.5  2021-02-01 00:01:30.738     4.6  2021-02-01 00:01:30.938     3.5  

I also have an hourly threshold as follows

                        Upper  Date                           2021-02-01 00:00:00  4.709884  2021-02-01 01:00:00  1.356615  2021-02-01 02:00:00  0.667457  2021-02-01 03:00:00  0.628824  2021-02-01 04:00:00  0.642154  

My goal is to compare and find all ticks that are above the threshold for the given hour. For example I want to compare all ticks between 2021-02-01 00:00:00 and 00:59:59 with the threshold for 2021-02-01 00:00:00 from the second dataframe and so on for the duration of the month.

I've tried using groupby() to group the ticks into (date, hour), but I have no idea how to automate the process of finding values above the corresponding threshold for a whole months worth of data.

Any help would be greatly appreciated.

https://stackoverflow.com/questions/66609534/python-pandas-compare-ticks-with-differing-intervals-to-hourly-data March 13, 2021 at 10:21AM

没有评论:

发表评论