recpack.preprocessing.filters.NMostRecent
- class recpack.preprocessing.filters.NMostRecent(N: int, item_ix: str, timestamp_ix: str)
Select only events on the N most recently visited items.
If there is a tie, the first occuring item in the DataFrame is retained.
- Parameters
N (int) – Number of items to retain.
item_ix (str) – Name of the column in which item identifiers are listed.
timestamp_ix (str, optional) – Name of the column in which timestamps are listed, defaults to None
Methods
apply
(df)Apply Filter to the DataFrame passed.
apply_all
(*dfs)Apply the filter to a list of pandas DataFrames.
- apply(df)
Apply Filter to the DataFrame passed.
- Parameters
df (pd.DataFrame) – DataFrame to filter
- apply_all(*dfs: pandas.core.frame.DataFrame) List[pandas.core.frame.DataFrame]
Apply the filter to a list of pandas DataFrames.
The filter is applied independently to each of the DataFrames.
- Returns
The list of processed DataFrames
- Return type
List[pd.DataFrame]