chap_core.time_period package

Submodules

chap_core.time_period.date_util_wrapper module

class chap_core.time_period.date_util_wrapper.DateUtilWrapper(date: datetime)[source]

Bases: object

class chap_core.time_period.date_util_wrapper.Day(date: datetime | Number, *args, **kwargs)[source]

Bases: TimePeriod

property id
to_string()[source]
topandas()[source]
class chap_core.time_period.date_util_wrapper.Month(date: datetime | Number, *args, **kwargs)[source]

Bases: TimePeriod

property id
to_string()[source]
topandas()[source]
class chap_core.time_period.date_util_wrapper.PeriodRange(start_timestamp: TimeStamp, end_timestamp: TimeStamp, time_delta: TimeDelta)[source]

Bases: BNPDataClass

concatenate(other: PeriodRange) PeriodRange[source]
property delta
property end_timestamp
classmethod from_ids(ids: Iterable[str], fill_missing=False)[source]
classmethod from_pandas(periods: Iterable[Period])[source]
classmethod from_period_list(fill_missing, periods)[source]
classmethod from_start_and_n_periods(start_period: Period, n_periods: int)[source]
classmethod from_strings(period_strings: Iterable[str], fill_missing=False)[source]
classmethod from_time_periods(start_period: TimePeriod, end_period: TimePeriod)[source]
classmethod from_timestamps(start_timestamp: TimeStamp, end_timestamp: TimeStamp, time_delta: TimeDelta)[source]
property month
searchsorted(period: TimePeriod, side='left')[source]

Find the index where the period would be inserted to maintain order

property shape
property start_timestamp
to_period_index()[source]
todict()[source]

Convert the data into a dictionary with the field names as keys and the corresponding data as values.

Returns

dict[str, ArrayLike]

tolist()[source]

Convert the data into a list of entries from the corrsponding dataclass with normal python types. Similar to np.tolist and pd.tolist. This is good for debugging, but for real applications requires a lot of memory allocation. For iterating over the data, use toiter instead.

Returns

list[cls.dataclass]

topandas()[source]

Convert the data into a pandas DataFrame with the fields as columns

Returns

pandas.DataFrame

property week
property year
class chap_core.time_period.date_util_wrapper.TimeDelta(relative_delta: relativedelta)[source]

Bases: DateUtilWrapper

n_periods(start_stamp: TimeStamp, end_stamp: TimeStamp)[source]
class chap_core.time_period.date_util_wrapper.TimePeriod(date: datetime | Number, *args, **kwargs)[source]

Bases: object

property end_timestamp
classmethod from_id(id: str)[source]
classmethod from_pandas(period: Period)[source]
property id
property last_day
property n_days
classmethod parse(text_repr: str)[source]
classmethod parse_week(week: str)[source]
property start_timestamp
property time_delta: TimeDelta
classmethod timestamp_diff(first_timestamp: TimeStamp, second_timestamp: TimeStamp)[source]
class chap_core.time_period.date_util_wrapper.TimeStamp(date: datetime)[source]

Bases: DateUtilWrapper

property date: datetime
classmethod parse(text_repr: str)[source]
property week
class chap_core.time_period.date_util_wrapper.Week(date, *args, **kwargs)[source]

Bases: TimePeriod

property id
to_string()[source]
topandas()[source]
class chap_core.time_period.date_util_wrapper.WeekNumbering[source]

Bases: object

static get_date(year: int, week: int, day: int) datetime[source]
static get_week_info(date: datetime) Tuple[int, int, int][source]
class chap_core.time_period.date_util_wrapper.Year(date: datetime | Number, *args, **kwargs)[source]

Bases: TimePeriod

property id
to_string()[source]
topandas()[source]
chap_core.time_period.date_util_wrapper.clean_timestring(timestring: str)[source]
chap_core.time_period.date_util_wrapper.convert_time_period_string(row)[source]
chap_core.time_period.date_util_wrapper.parse(date_string: str, default: datetime = None)[source]

chap_core.time_period.multi_resolution module

chap_core.time_period.multi_resolution.pack_to_period(time_period, data, goal_period)[source]

chap_core.time_period.period_assignment module

class chap_core.time_period.period_assignment.PeriodAssignment(to_range: PeriodRange, from_range: PeriodRange)[source]

Bases: object

Matches two period ranges with possibly different time deltas and gives assignments to each period in the first range.

chap_core.time_period.relationships module

chap_core.time_period.relationships.previous(period: TimePeriod) TimePeriod[source]

Module contents

class chap_core.time_period.Day(date: datetime | Number, *args, **kwargs)[source]

Bases: TimePeriod

property id
to_string()[source]
topandas()[source]
class chap_core.time_period.Month(date: datetime | Number, *args, **kwargs)[source]

Bases: TimePeriod

property id
to_string()[source]
topandas()[source]
class chap_core.time_period.PeriodRange(start_timestamp: TimeStamp, end_timestamp: TimeStamp, time_delta: TimeDelta)[source]

Bases: BNPDataClass

concatenate(other: PeriodRange) PeriodRange[source]
property delta
property end_timestamp
classmethod from_ids(ids: Iterable[str], fill_missing=False)[source]
classmethod from_pandas(periods: Iterable[Period])[source]
classmethod from_period_list(fill_missing, periods)[source]
classmethod from_start_and_n_periods(start_period: Period, n_periods: int)[source]
classmethod from_strings(period_strings: Iterable[str], fill_missing=False)[source]
classmethod from_time_periods(start_period: TimePeriod, end_period: TimePeriod)[source]
classmethod from_timestamps(start_timestamp: TimeStamp, end_timestamp: TimeStamp, time_delta: TimeDelta)[source]
property month
searchsorted(period: TimePeriod, side='left')[source]

Find the index where the period would be inserted to maintain order

property shape
property start_timestamp
to_period_index()[source]
todict()[source]

Convert the data into a dictionary with the field names as keys and the corresponding data as values.

Returns

dict[str, ArrayLike]

tolist()[source]

Convert the data into a list of entries from the corrsponding dataclass with normal python types. Similar to np.tolist and pd.tolist. This is good for debugging, but for real applications requires a lot of memory allocation. For iterating over the data, use toiter instead.

Returns

list[cls.dataclass]

topandas()[source]

Convert the data into a pandas DataFrame with the fields as columns

Returns

pandas.DataFrame

property week
property year
class chap_core.time_period.TimePeriod(date: datetime | Number, *args, **kwargs)[source]

Bases: object

property end_timestamp
classmethod from_id(id: str)[source]
classmethod from_pandas(period: Period)[source]
property id
property last_day
property n_days
classmethod parse(text_repr: str)[source]
classmethod parse_week(week: str)[source]
property start_timestamp
property time_delta: TimeDelta
classmethod timestamp_diff(first_timestamp: TimeStamp, second_timestamp: TimeStamp)[source]
class chap_core.time_period.Week(date, *args, **kwargs)[source]

Bases: TimePeriod

property id
to_string()[source]
topandas()[source]
class chap_core.time_period.Year(date: datetime | Number, *args, **kwargs)[source]

Bases: TimePeriod

property id
to_string()[source]
topandas()[source]
chap_core.time_period.get_period_range(start_period: TimePeriod, end_period: TimePeriod)