rolling#

rolling(data, window=7, operation='mean', replacenans=None, **kwargs)[source]#

Alias to pandas.Series.rolling() (window) method to smooth a series.

Parameters:
  • data (list/arr) – the 1D or 2D data to be smoothed

  • window (int) – the length of the window

  • operation (str) – the operation to perform: ‘mean’ (default), ‘median’, ‘sum’, or ‘none’

  • replacenans (bool/float) – if None, leave NaNs; if False, remove them; if a value, replace with that value; if the string ‘nearest’ or ‘linear’, do interpolation (see sc.rmnans() for details)

  • kwargs (dict) – passed to pandas.Series.rolling()

Example:

data = [5,5,5,0,0,0,0,7,7,7,7,0,0,3,3,3]
rolled = sc.rolling(data, replacenans='nearest')