flexmeasures.data.services.time_series

Functions

flexmeasures.data.services.time_series.aggregate_values(bdf_dict: dict[Any, BeliefsDataFrame]) BeliefsDataFrame
flexmeasures.data.services.time_series.drop_unchanged_beliefs(bdf: BeliefsDataFrame) BeliefsDataFrame

Drop beliefs that are already stored in the database with an earlier belief time.

Also drop beliefs that are already in the data with an earlier belief time.

Quite useful function to prevent cluttering up your database with beliefs that remain unchanged over time.

flexmeasures.data.services.time_series.remove_existing_beliefs(bdf: BeliefsDataFrame, bdf_db: BeliefsDataFrame) BeliefsDataFrame

Remove beliefs that already exist in the database from the given BeliefsDataFrame.

This function filters out beliefs that are already stored in the database, proactively preventing unique constraint violations, for example, when re-running forecasters or reporters.

The function assumes the input BeliefsDataFrame has a unique source. It compares beliefs based on their event start time, belief horizon, and value, and removes any beliefs found in the database.

Parameters:
  • bdf – BeliefsDataFrame to filter. Must contain beliefs with a single unique source.

  • bdf_db – BeliefsDataFrame containing beliefs from the database.

Returns:

Filtered BeliefsDataFrame with existing beliefs removed. Returns an empty BeliefsDataFrame if all beliefs already exist in the database.