The default behavior for adding and solving with noisemodels has changed from Pastas 1.5. Find more information here

TimeSeries#

class TimeSeries(series, name=None, settings=None, metadata=None)[source]#

Class that deals with all user-provided time series.

Parameters
  • series (pandas.Series) – pandas.Series with pandas.DatetimeIndex.

  • name (str, optional) – String with the name of the time series, if None is provided, pastas will try to derive the name from the series.

  • settings (str or dict, optional) – The settings of the stress. This can be a string referring to a predefined settings dictionary (defined in ps.rcParams[“timeseries”]), or a dictionary with the settings to apply. For more information refer to Time series settings section below.

  • metadata (dict, optional) – Dictionary with metadata of the time series.

Returns

series – Returns a pastas.TimeSeries object.

Return type

pastas.TimeSeries

Time series settings
  • fill_nan ({“drop”, “mean”, “interpolate”} or float) –

    Method for filling NaNs.
    • drop: drop NaNs from time series

    • mean: fill NaNs with mean value of time series

    • interpolate: fill NaNs by interpolating between finite values

    • float: fill NaN with provided value, e.g. 0.0

  • fill_before ({“mean”, “bfill”} or float) –

    Method for extending time series into past.
    • mean: extend time series into past with mean value of time series

    • bfill: extend time series into past by back-filling first value

    • float: extend time series into past with provided value, e.g. 0.0

  • fill_after ({“mean”, “ffill”} or float) –

    Method for extending time series into future.
    • mean: extend time series into future with mean value of time series

    • ffill: extend time series into future by forward-filling last value

    • float: extend time series into future with provided value, e.g. 0.0

  • sample_up ({“mean”, “interpolate”, “divide”} or float) – Method for up-sampling time series (increasing frequency, e.g. going from weekly to daily values).

    • bfill or backfill: fill up-sampled time steps by back-filling current values

    • ffill or pad: fill up-sampled time steps by forward-filling current values

    • mean: fill up-sampled time steps with mean of timeseries

    • interpolate: fill up-sampled time steps by interpolating between current values

    • divide: fill up-sampled steps with current value divided by length of current time steps (i.e. spread value over new time steps).

  • sample_down ({“mean”, “drop”, “sum”, “min”, “max”}) – Method for down-sampling time series (decreasing frequency, e.g. going from daily to weekly values).

    • mean: resample time series by taking the mean

    • drop: resample the time series by taking the mean, dropping any NaN-values

    • sum: resample time series by summing values

    • max: resample time series with maximum value

    • min: resample time series with minimum value

Examples

To obtain the predefined TimeSeries settings, you can run the following line of code:

>>> ps.rcParams["timeseries"]

See also

pastas.timeseries.TimeSeries.update_series

For the individual options for the different settings.

Attributes#

series

series_original

Methods#

__init__

to_dict

Method to export the Time Series to a json format.

update_series

Method to update the series with new options.