timestep_weighted_resample(s, index, fast=False)[source]#

Resample a time series to a new time index, using an overlapping period weighted average.

The original series and the new index do not have to be equidistant. Also, the timestep-edges of the new index do not have to overlap with the original series.

It is assumed the series consists of measurements that describe a flux intensity that for each record starts at the previous index and ends at its own index. So the index of the series describes the end of the period for a given measurement.

When upsampling, the values are uniformly spread over the new timestep (like bfill). When downsampling, the values are aggregated to the new index. When the start and end of the new index do not overlap with the series (eg: resampling pecipitation from 9:00 to 0:00), new values are calculated by combining original measurements.

Compared to the resample methods in Pandas, this method is more accurate for non-equidistant series.

  • s (pandas.Series) – The original series to be resampled

  • index (pandas.Index) – The index to which to resample the series

  • fast (bool, optional) – use fast implementation, default is False


s_new – The resampled series

Return type: