From 20545e2cefe75ea897776704fd74cf3c86dc17b4 Mon Sep 17 00:00:00 2001 From: svittoz <137794505+svittoz@users.noreply.github.com> Date: Mon, 10 Jun 2024 12:32:34 +0200 Subject: [PATCH] fix possible column error in omop_teva --- eds_scikit/plot/omop_teva.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/eds_scikit/plot/omop_teva.py b/eds_scikit/plot/omop_teva.py index 06ce1a5e..eac15404 100644 --- a/eds_scikit/plot/omop_teva.py +++ b/eds_scikit/plot/omop_teva.py @@ -101,9 +101,15 @@ def generate_omop_teva( else: try: table = data._read_table(table_name) - table = table.merge( - visit_occurrence, on="visit_occurrence_id", how="left" - ) + drop_columns = (set(visit_occurrence.columns).intersection(table.columns)).difference(["visit_occurrence_id"]) + if drop_columns: + table = table.merge( + visit_occurrence.drop(columns=drop_columns), on="visit_occurrence_id", how="left" + ) + else: + table = table.merge( + visit_occurrence, on="visit_occurrence_id", how="left" + ) except AttributeError: raise Exception( f"No {table_name} table in input data object. Skipping procedure_occurrence."