filter_rows()
Filter out rows where values are not in the allowed codelist.
Usage
filter_rows(
df,
codelist_ids,
)Compares as strings but does not change DataFrame dtypes. Does not mutate the input DataFrame.
Parameters
df: pd.DataFrame-
The input DataFrame.
codelist_ids: dict[str, list[str]]- A mapping of column names to allowed codelist IDs.
Returns
pd.DataFrame- A filtered copy of the DataFrame containing only selected rows.