eelib.utils.resample

Methods for inter- or extrapolating timeseries data (in pandas Dataframe format).

Author: elenia@TUBS
Copyright 2024 elenia
This file is part of eELib, which is free software under the terms of the GNU GPL Version 3.

Module Contents

Functions

get_resolution_pandas_timeseries(→ int)

Computes the time resolution of a given timeseries.

resample_pandas_timeseries_agg(→ pandas.DataFrame)

Resample a given DataFrame to a target time resolution.

Attributes

_logger

_logger
get_resolution_pandas_timeseries(timeseries: pandas.DataFrame | pandas.Series) int

Computes the time resolution of a given timeseries.

TODO (1) handle if not DataFrame or Series (2) handle if not a DatetimeIndex

Parameters:

timeseries (pd.DataFrame | pd.Series) – pandas Timeseries to determine resolution

Returns:

time resolution in seconds

Return type:

int

resample_pandas_timeseries_agg(df: pandas.DataFrame, target_resolution: int, ffill_columns: list = [], distribute_columns: list = [], key: str = '') pandas.DataFrame

Resample a given DataFrame to a target time resolution.

Columns that must be uniformly distributed or just filled forward

Parameters:
  • df (pd.DataFrame) – The df to be resampled.

  • target_resolution (int) – The resolution to be sampled in (seconds).

  • ffill_columns (list) – Columns to be filled forward. Defaults to [].

  • distribute_columns (list) – Columns to be distributed. Defaults to [].

  • key (str) – Key to describe the series (just for logging). Defaults to “”.

Returns:

the resampled DataFrame

Return type:

pd.DataFrame