qis.TimePeriod¶
- class qis.TimePeriod(start=None, end=None, tz=None)[source]¶
Bases:
objecta start and end date, with the conversions and slicing every qis function expects.
The canonical way to express a window in this stack. Pass a TimePeriod rather than masking an index by hand:
time_period.locate(df)applies the same inclusive convention everywhere, and the tz is carried with the period so a tz-aware frame is not silently compared against naive timestamps.Either bound may be None, meaning open-ended on that side.
startandendaccept pd.Timestamp, datetime, str, int, or an Enum whose value is one of those:'12/31/2019'— month/day/year'31Dec2019'20191231as a string — year/month/day2019as an int — 1 January of that year
- Parameters:
start (SUPPORTED_TYPES) – start of the window, or None for open-ended
end (SUPPORTED_TYPES) – end of the window, or None for open-ended
tz (str) – timezone applied to both bounds
- Raises:
TypeError – if a bound is of a type not listed above
- __init__(start=None, end=None, tz=None)[source]¶
- Parameters:
start (SUPPORTED_TYPES)
end (SUPPORTED_TYPES)
tz (str)
Methods
__init__([start, end, tz])copy()end_to_str([format])fill_outside(df[, fill_value])fill given value outside of timeperiod
locate(df)truncate timeseries data to given timeperiod
print()shift_end_date_by_days([backward, num_days])shift_start_date_by_days([backward, num_days])start_to_str([format])to_pd_datetime_index([freq, hour_offset, ...])generate pd dt_time index
to_period_dates_str([freq, tz, date_format, ...])nb.
to_str([date_separator, ...])tz_localize([tz])Attributes
- to_pd_datetime_index(freq='B', hour_offset=None, tz=None, include_start_date=False, include_end_date=False, is_business_dates=True, days_shift=None)[source]¶
generate pd dt_time index
- to_period_dates_str(freq='B', tz=None, date_format='%Y%m%d', holidays=None)[source]¶
nb. can pass calendar pd.date_range(holidays=holidays)