pyspark.pandas.window.Rolling.kurt#

Rolling.kurt()[source]#

Calculate unbiased rolling kurtosis.

Note

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.

Returns:
Series or DataFrame

Returns the same object type as the caller of the rolling calculation.

See also

pyspark.pandas.Series.rolling

Calling object with Series data.

pyspark.pandas.DataFrame.rolling

Calling object with DataFrames.

pyspark.pandas.Series.var

Equivalent method for Series.

pyspark.pandas.DataFrame.var

Equivalent method for DataFrame.

numpy.var

Equivalent method for Numpy array.

Examples

>>> s = ps.Series([5, 5, 6, 7, 5, 1, 5, 9])
>>> s.rolling(4).kurt()
0         NaN
1         NaN
2         NaN
3   -1.289256
4   -1.289256
5    2.234867
6    2.227147
7    1.500000
dtype: float64

For DataFrame, each unbiased rolling variance is computed column-wise.

>>> df = ps.DataFrame({"A": s.to_numpy(), "B": s.to_numpy() ** 2})
>>> df.rolling(5).kurt()
          A         B
0       NaN       NaN
1       NaN       NaN
2       NaN       NaN
3       NaN       NaN
4  0.312500  0.906336
5  2.818047  1.016942
6  2.818047  1.016942
7  0.867769  0.389750