From e9e21776440d53979488558c8e5f2c097af4d0f5 Mon Sep 17 00:00:00 2001 From: Dainius Kirsnauskas Date: Wed, 29 May 2024 06:42:48 +0300 Subject: [PATCH] match -> elif --- GUI/back-end/data_collection/refactoring.py | 29 ++++++++++----------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/GUI/back-end/data_collection/refactoring.py b/GUI/back-end/data_collection/refactoring.py index efcf1f1..7f1cc47 100644 --- a/GUI/back-end/data_collection/refactoring.py +++ b/GUI/back-end/data_collection/refactoring.py @@ -20,21 +20,20 @@ def set_lovd_dtypes(df_dict): for column in frame.columns: if column not in LOVD_TABLES_DATA_TYPES[table_name]: raise ValueError(f"Column {column} is undefined in LOVD_TABLES_DATA_TYPES") - - match LOVD_TABLES_DATA_TYPES[table_name][column]: - case "Date": - frame[column] = pd.to_datetime(frame[column], errors='coerce') - case "Boolean": - frame[column] = frame[column].map({"0": False, "1": True}) - case "String": - frame[column] = frame[column].astype('string') - case "Integer": - frame[column] = pd.to_numeric(frame[column]).astype('Int64') - case "Double": - frame[column] = pd.to_numeric(frame[column]).astype('float') - case _: - raise ValueError(f"Undefined data type: " - f"{LOVD_TABLES_DATA_TYPES[table_name][column]}") + var = LOVD_TABLES_DATA_TYPES[table_name][column] + if var == "Date": + frame[column] = pd.to_datetime(frame[column], errors='coerce') + elif var == "Boolean": + frame[column] = frame[column].map({"0": False, "1": True}) + elif var == "String": + frame[column] = frame[column].astype('string') + elif var == "Integer": + frame[column] = pd.to_numeric(frame[column]).astype('Int64') + elif var == "Double": + frame[column] = pd.to_numeric(frame[column]).astype('float') + else: + raise ValueError(f"Undefined data type: " + f"{LOVD_TABLES_DATA_TYPES[table_name][column]}") def parse_lovd(path=LOVD_PATH + '/lovd_data.txt'):