def test_interval_datetime_end_date_exclusive_by_undershooting(self): start_time = datetime.strptime('2010/04/01 00:00:00', '%Y/%m/%d %H:%M:%S') end_time = datetime.strptime('2010/12/31 23:59:00', '%Y/%m/%d %H:%M:%S') result = filters.filter_on_interval_datetime(self.interval_datetime_data, start_time=start_time, end_time=end_time)\ .reset_index(drop=True) aim = pd.DataFrame({'INTERVAL_DATETIME': []}) aim['INTERVAL_DATETIME'] = pd.to_datetime(aim['INTERVAL_DATETIME'], format='%Y/%m/%d %H:%M:%S') assert_frame_equal(aim, result)
def test_interval_datetime_pick_none_of_two_by_overshooting_date(self): start_time = datetime.strptime('2018/04/01 00:00:00', '%Y/%m/%d %H:%M:%S') end_time = datetime.strptime('2019/05/01 00:13:00', '%Y/%m/%d %H:%M:%S') result = filters.filter_on_interval_datetime(self.interval_datetime_data, start_time=start_time, end_time=end_time)\ .reset_index(drop=True) aim = pd.DataFrame({'INTERVAL_DATETIME': []}) aim['INTERVAL_DATETIME'] = pd.to_datetime(aim['INTERVAL_DATETIME'], format='%Y/%m/%d %H:%M:%S') assert_frame_equal(aim, result)
def test_interval_datetime_pick_first_of_two(self): start_time = datetime.strptime('2010/06/01 00:00:00', '%Y/%m/%d %H:%M:%S') end_time = datetime.strptime('2011/09/01 00:13:00', '%Y/%m/%d %H:%M:%S') result = filters.filter_on_interval_datetime( self.interval_datetime_data, start_time=start_time, end_time=end_time) aim = pd.DataFrame({'INTERVAL_DATETIME': ['2011/01/01 00:00:00']}) aim['INTERVAL_DATETIME'] = pd.to_datetime(aim['INTERVAL_DATETIME'], format='%Y/%m/%d %H:%M:%S') assert_frame_equal(aim, result)
def test_interval_datetime_pick_two_of_two_by_overlaping_interval(self): start_time = datetime.strptime('2010/12/31 23:59:00', '%Y/%m/%d %H:%M:%S') end_time = datetime.strptime('2015/05/01 00:00:00', '%Y/%m/%d %H:%M:%S') aim = pd.DataFrame({ 'INTERVAL_DATETIME': ['2011/01/01 00:00:00', '2015/01/01 00:00:00'] }) result = filters.filter_on_interval_datetime(self.interval_datetime_data, start_time=start_time, end_time=end_time)\ .reset_index(drop=True) aim['INTERVAL_DATETIME'] = pd.to_datetime(aim['INTERVAL_DATETIME'], format='%Y/%m/%d %H:%M:%S') assert_frame_equal(aim, result)