pyspark.pandas.window.Rolling.min#

Rolling.min()[source]#

Calculate the rolling minimum.

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

Returned object type is determined by the caller of the rolling calculation.

See also

pyspark.pandas.Series.rolling

Calling object with a Series.

pyspark.pandas.DataFrame.rolling

Calling object with a DataFrame.

pyspark.pandas.Series.min

Similar method for Series.

pyspark.pandas.DataFrame.min

Similar method for DataFrame.

Examples

>>> s = ps.Series([4, 3, 5, 2, 6])
>>> s
0    4
1    3
2    5
3    2
4    6
dtype: int64
>>> s.rolling(2).min()
0    NaN
1    3.0
2    3.0
3    2.0
4    2.0
dtype: float64
>>> s.rolling(3).min()
0    NaN
1    NaN
2    3.0
3    2.0
4    2.0
dtype: float64

For DataFrame, each rolling minimum is computed column-wise.

>>> df = ps.DataFrame({"A": s.to_numpy(), "B": s.to_numpy() ** 2})
>>> df
   A   B
0  4  16
1  3   9
2  5  25
3  2   4
4  6  36
>>> df.rolling(2).min()
     A    B
0  NaN  NaN
1  3.0  9.0
2  3.0  9.0
3  2.0  4.0
4  2.0  4.0
>>> df.rolling(3).min()
     A    B
0  NaN  NaN
1  NaN  NaN
2  3.0  9.0
3  2.0  4.0
4  2.0  4.0