From 1e6f9ff0fbd5d76dcc37f2bf16c32bb4e20018bd Mon Sep 17 00:00:00 2001 From: "Julian.Endres" Date: Fri, 15 Mar 2024 10:09:20 +0100 Subject: [PATCH] Write scalars as scalars and not as lists --- data_adapter_oemof/build_datapackage.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/data_adapter_oemof/build_datapackage.py b/data_adapter_oemof/build_datapackage.py index 266da98..f955aae 100644 --- a/data_adapter_oemof/build_datapackage.py +++ b/data_adapter_oemof/build_datapackage.py @@ -80,9 +80,15 @@ def _listify_to_periodic(group_df) -> pd.Series: ) # throw out the index values = group_df[col].unique() if len(values) > 1: - unique_values[col] = list(group_df[col]) + if isinstance(group_df[col].iloc[0], list): + unique_values[col] = list(group_df[col].apply(lambda x: x[0])) + else: + unique_values[col] = list(group_df[col]) else: - unique_values[col] = group_df[col].iloc[0] + if isinstance(group_df[col].iloc[0], list): + unique_values[col] = group_df[col].iat[0][0] + else: + unique_values[col] = group_df[col].iat[0] unique_values["name"] = "_".join(group_df.name) unique_values.drop("year") return unique_values