We currently do this in simulation.result:
def _codes_to_categorical(
*,
codes: pd.Series,
categories: tuple[str, ...],
) -> pd.Categorical | pd.Series:
but users may well want to check their own data against this. So it would be neat to have a pd.CategoricalDtype returned from something like:
@categorical
class WorkingStatus:
retired: int
working: int
WorkingStatus.to_categorical_dtype()
Added benefit would be that we could use it on any data even if it might not have all outcomes and the dtype will always be correct.
We currently do this in
simulation.result:but users may well want to check their own data against this. So it would be neat to have a
pd.CategoricalDtypereturned from something like:Added benefit would be that we could use it on any data even if it might not have all outcomes and the dtype will always be correct.