https://www.rdocumentation.org/packages/dplyr/versions/1.0.10/topics/case_when
As an alternative to
def get_bound_status(df: pd.Series) -> str:
""" returns one of ['upper', 'lower', 'none'] """
...
model_matrix = (
model_matrix
.assign(bounded_by = lambda df: df.apply(get_bound_status, axis=1))
)
https://www.rdocumentation.org/packages/dplyr/versions/1.0.10/topics/case_when
As an alternative to