From 7d88a16a5aa6a23e1495eba007d2f9b181b76d5e Mon Sep 17 00:00:00 2001 From: davidshaw-uw Date: Mon, 31 Jul 2023 10:10:28 -0700 Subject: [PATCH] coerce dtypes to objects --- src/onemod/models/swimr_model.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/onemod/models/swimr_model.py b/src/onemod/models/swimr_model.py index 93dc4b1d..9206bb02 100644 --- a/src/onemod/models/swimr_model.py +++ b/src/onemod/models/swimr_model.py @@ -169,6 +169,12 @@ def swimr_model(experiment_dir: Union[Path, str], submodel_id: str) -> None: df_pred["holdout_id"] = holdout_id df_pred["location_id"] = pd.to_numeric(df_pred["location_id"]) df_pred["sex_id"] = df_input["sex_id"].unique()[0] + + # Since we are merging on columns specified in the col_id list, ensure they are the correct + # datatypes. + for id_col in settings["col_id"]: + df_pred[id_col] = df_pred[id_col].astype(df_input[id_col].dtype) + df_pred = df_pred.merge( right=df_input[as_list(settings["col_id"]) + ["test", settings["col_pred"]]], on=settings["col_id"],