def test_daterange_closedclosed_no_tz(): date_range = DateRange(dt(2013, 1, 1), dt(2014, 2, 1), OPEN_OPEN) expected = DateRange(dt(2013, 1, 1, 0, 0, 0, 1000, tzinfo=mktz()), dt(2014, 1, 31, 23, 59, 59, 999000, tzinfo=mktz()), CLOSED_CLOSED) act = to_pandas_closed_closed(date_range) assert act == expected
def filter(self, data, range_obj): """ ensures data is properly subset to the range in range_obj. (Depending on how the chunking is implemented, it might be possible to specify a chunk range that reads out more than the actual range eg: date range, chunked monthly. read out 2016-01-01 to 2016-01-02. This will read ALL of January 2016 but it should be subset to just the first two days) returns ------- data, filtered by range_obj """ if isinstance(range_obj, (pd.DatetimeIndex, tuple)): range_obj = DateRange(range_obj[0], range_obj[-1]) range_obj = to_pandas_closed_closed(range_obj, add_tz=False) start = range_obj.start end = range_obj.end if 'date' in data.index.names: return data[start:end] elif 'date' in data.columns: if start and end: return data[(data.date >= start) & (data.date <= end)] elif start: return data[(data.date >= start)] elif end: return data[(data.date <= end)] else: return data else: return data
def test_daterange_closedclosed_no_tz(): date_range = DateRange(dt(2013, 1, 1), dt(2014, 2, 1), OPEN_OPEN) expected = DateRange( dt(2013, 1, 1, 0, 0, 0, 1000, tzinfo=mktz()), dt(2014, 1, 31, 23, 59, 59, 999000, tzinfo=mktz()), CLOSED_CLOSED ) act = to_pandas_closed_closed(date_range) assert act == expected
def test_daterange_closedclosed_None(): assert to_pandas_closed_closed(None) is None