mode¶
-
mode
(x, w=Window(w=None, r=0))[source]¶ Most common value in series over given window
- Parameters
x (
Series
) – series: timeseriesw (
Union
[Window
,int
]) – Window or int: number of observations and ramp up to use. e.g. Window(22, 10) where 22 is the window size
and 10 the ramp up value. Window size defaults to length of series. :rtype:
Series
:return: timeseries of mode valueUsage
Computes the mode over a given window. For each window, this function will return the most common value of all elements in the window. If there are multiple values with the same frequency of occurrence, will return the smallest value.
If window is not provided, computes mode over the full series.
Examples
Generate price series and compute mode over \(22\) observations
>>> prices = generate_series(100) >>> mode(prices, 22)
See also