Skip to content

Commit

Permalink
fix _clean_belief_dataframe for a BDF with a single index. (#1019)
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
  • Loading branch information
victorgarcia98 committed Mar 25, 2024
1 parent 27c8b70 commit d9ae183
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions flexmeasures/data/models/reporting/pandas_reporter.py
Expand Up @@ -168,9 +168,18 @@ def _clean_belief_dataframe(
# filing the missing indexes with default values:
if "belief_time" not in bdf.index.names:
if belief_horizon is not None:
belief_time = (
bdf["event_start"] + +bdf.event_resolution - belief_horizon
)

# In case that all the index but `event_start` are dropped
if (
isinstance(bdf.index, pd.DatetimeIndex)
and bdf.index.name == "event_start"
):
event_start = bdf.index
else:
event_start = bdf.index.get_event_values("event_start")

belief_time = event_start + bdf.event_resolution - belief_horizon

else:
belief_time = [belief_time] * len(bdf)
bdf["belief_time"] = belief_time
Expand Down

0 comments on commit d9ae183

Please sign in to comment.