Skip to content

Commit

Permalink
Merge pull request #76 from sedos-project/fix/write_scalars_not_as_lists
Browse files Browse the repository at this point in the history
Write scalars as scalars and not as lists
  • Loading branch information
nailend authored Mar 22, 2024
2 parents ba3830b + 1e6f9ff commit fabd98b
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions data_adapter_oemof/build_datapackage.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,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
Expand Down

0 comments on commit fabd98b

Please sign in to comment.