seismometer.data.pandas_helpers.event_score

seismometer.data.pandas_helpers.event_score(merged_frame, pks, score, ref_event=None, aggregation_method='max')

Reduces a dataframe of all predictions to a single row of significance; such as the max or most recent value for an entity. Supports max/min for value only scores, and last/first if a reference timestamp is provided.

Parameters:
  • merged_frame (pd.DataFrame) – The dataframe with score and event data, such as those having an event added via merge_windowed_event.

  • pks (list[str]) – A list of identifying keys on which to aggregate, such as Id.

  • score (str) – The column name containing the score value.

  • ref_event (Optional[str], optional) – The column name containing the time to consider, by default None.

  • aggregation_method (str, optional) – A string describing the method to select a value, by default ‘max’.

Returns:

The reduced dataframe with one row per combination of pks.

Return type:

pd.DataFrame