mean() → Union[databricks.koalas.series.Series, databricks.koalas.frame.DataFrame]¶
Calculate the expanding mean of the values.
the current implementation of this API uses Spark’s Window without specifying partition specification. This leads to move all data into single partition in single machine and could cause serious performance degradation. Avoid this method against very large dataset.
- Series or DataFrame
Returned object type is determined by the caller of the expanding calculation.
Calling object with Series data.
Calling object with DataFrames.
Equivalent method for Series.
Equivalent method for DataFrame.
The below examples will show expanding mean calculations with window sizes of two and three, respectively.
>>> s = ks.Series([1, 2, 3, 4]) >>> s.expanding(2).mean() 0 NaN 1 1.5 2 2.0 3 2.5 dtype: float64
>>> s.expanding(3).mean() 0 NaN 1 NaN 2 2.0 3 2.5 dtype: float64