hpipy.period_table.PeriodTable#
- class hpipy.period_table.PeriodTable(trans_df, period_table=None)[source]
- Bases: - object- Period table class. - Organizes transaction data into defined time periods. - Parameters:
- trans_df (pd.DataFrame) – Transaction data. 
- period_table (pd.DataFrame | None) – Period table. 
 
 - trans_df
- Transaction data. - Type:
- pd.DataFrame 
 
 - period_table
- Period table. - Type:
- pd.DataFrame 
 
 - Methods - Initialize period table. - Create a period table from a transaction dataframe. - Attributes - __init__(trans_df, period_table=None)[source]
- Initialize period table. - Parameters:
- trans_df (pd.DataFrame) – Transaction data. 
- period_table (pd.DataFrame | None) – Period table. 
 
- Raises:
- TypeError – If ‘trans_df’ is not or does not inherit from a DataFrame. 
- Return type:
- None 
 
 - trans_df: DataFrame
 - period_table: DataFrame
 - create_period_table(date, periodicity=None, nbr_periods=None, freq=None, start=None, min_date=None, max_date=None, adj_type='move', **kwargs)[source]
- Create a period table from a transaction dataframe. - Parameters:
- date (str) – Date field. 
- periodicity (str | None, optional) – Periodicity of the table. Defaults to None. 
- nbr_periods (int | None, optional) – Number of periods (only used if periodicity is “equalsample”). Defaults to None. 
- freq (int | None, optional) – Frequency in days (only used if periodicity is “equalfreq”). Defaults to None. 
- start (str | None, optional) – Starting position (only used if periodicity is “equalfreq”). One of “first” or “last”. Defaults to None. 
- min_date (str | None, optional) – Minimum date. Defaults to None. 
- max_date (str | None, optional) – Maximum dare. Defaults to None. 
- adj_type (str | None, optional) – Adjustment type. Defaults to “move”. 
- **kwargs – Additional keyword arguments. 
 
- Returns:
- Period table. 
- Return type:
- Self