Preprocess

Timeseries

aftercovid.preprocess.ts_moving_average(series, n=7, center=True)[source]

Computes the moving average of a differential series. The function handles nan as well. The outputs does not contain any nan unless there are too many consecutive nans.

Parameters:
  • series – timeseries

  • n – window

  • center – centered average

Returns:

moving average (of same size)

aftercovid.preprocess.ts_normalise_negative_values(series, n=7, extreme=4)[source]

series is a differential series which should not have any negative values. The function removes unexpected high value and negative value. These extremes are replaced by a local average. The function handles nan as well. The outputs does not contain any nan unless there are too many consecutive nans.

Parameters:
  • series – differential values

  • n – moving average

  • extreme – removes extreme values, if the series is higher or lower than its moverage * th or / th

Returns:

corrected series

aftercovid.preprocess.ts_remove_decreasing_values(series)[source]

Returns a series with no decreasing values (only growing). Data are sometimes normalized and show negative values but the past remains unchanged. This functions decreases past values until the series is growing.

Parameters:

series – series

Returns:

new series