pydpeet.df_primitives_correction#

pydpeet.df_primitives_correction(df_primitives, correction_config, data_columns, thresholds, reindex=True, reannotate=True)[source]#

Corrects the primitives in the dataframe based on the given configuration.

Parameters: df_primitives (pd.DataFrame): Input dataframe containing the primitives. correction_config (dict): Configuration for the correction, containing the following keys:

  • replace_ID (dict): Mapping of old IDs to new IDs.

  • replace_time (dict): Mapping of time ranges and the new labels for variable.

  • replace_time_and_merge (dict): Mapping of time ranges and the new labels for variable + merges all into one segment.

  • merge_left (list): List of IDs to merge with the previous segment.

  • merge_right (list): List of IDs to merge with the next segment.

  • merge_range (list): List of tuples of start and end IDs to merge. Keeping left Variable

Example: {‘replace_time’: {(0.0, 10.0): ‘I’, (10.0, 20.0): ‘P’}, …}

data_columns (dict): Mapping of column names to their respective short names.

Example: data_columns = {“I”: “Current[A]”, “P”: “Power[W]”, “V”: “Voltage[V]”}

thresholds (dict): Threshold values for each type of annotation.

Example: {“V”: 0.1, “I”: 0.1, “P”: 0.1}

reindex (bool): Whether to reindex the IDs to be consecutive, by default True. reannotate (bool): Whether to reannotate the primitives after the correction, by default True.

Returns: pd.DataFrame: The corrected dataframe with the added columns for annotated primitives.

Parameters:
Return type:

DataFrame