Skip to content

Commit

Permalink
Write scalars as scalars and not as lists
Browse files Browse the repository at this point in the history
  • Loading branch information
nailend committed Mar 15, 2024
1 parent 1aca1fc commit 1e6f9ff
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 @@ -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
Expand Down

0 comments on commit 1e6f9ff

Please sign in to comment.