pandas.api.typing.Expanding.last#

Expanding.last(numeric_only=False)[source]#

Calculate the expanding Last (right-most) element of the window.

At each point in time, returns the last value in the expanding window, which is the most recent observation in the data.

Parameters:
numeric_onlybool, default False

Include only float, int, boolean columns.

Returns:
Series or DataFrame

Return type is the same as the original object with np.float64 dtype.

See also

GroupBy.last

Similar method for GroupBy objects.

Expanding.first

Method to get the first element in each window.

Examples

The example below will show an expanding calculation with a window size of three.

>>> s = pd.Series(range(5))
>>> s.expanding(3).last()
0         NaN
1         NaN
2         2.0
3         3.0
4         4.0
dtype: float64