pastas.timeseries_utils.get_equidistant_series_nearest#

get_equidistant_series_nearest(series, freq, minimize_data_loss=False)[source]#

Get equidistant time series using nearest reindexing.

This method will shift observations to the nearest equidistant timestep to create an equidistant time series, if necessary. Each observation is guaranteed to only be used once in the equidistant time series.

Parameters
  • series (pandas.Series) – original (non-equidistant) time series

  • freq (str) – frequency of the new equidistant time series (i.e. “H”, “D”, “7D”, etc.)

  • minimize_data_loss (bool, optional) – if set to True, method will attempt use any unsampled points from original time series to fill some remaining NaNs in the new equidistant time series. Default is False. This only happens in rare cases.

Returns

s – equidistant time series

Return type

pandas.Series

Notes

This method creates an equidistant time series with specified freq using the nearest sampling (meaning observations can be shifted in time), with additional filling logic that ensures each original measurement is only included once in the new time series. Values are filled as close as possible to their original timestamp in the new equidistant time series.