def predict(df, inplace=True):
....
return_df = pd.DataFrame()
for i, param_name in enumerate(self.param_names):
return_df[param_name] = self.params[i].get_param(coefs[i], data)
if inplace:
df[param_name] = return_df[param_name]
return return_df
This way, the same default behavior is provided, but users passing in slices of dataframes or who in general rely on pure functions can also have that behavior enabled optionally.
Ideally, when we predict out on a fitted model, the predict method doesn't automatically modify the input dataset as it does here: https://github.com/ihmeuw-msca/regmod/blob/develop/src/regmod/models/model.py#L621
A proposed alternative:
This way, the same default behavior is provided, but users passing in slices of dataframes or who in general rely on pure functions can also have that behavior enabled optionally.