Skip to content

BUG: rolling().first() and rolling().last() don't work #62490

@k0ck

Description

@k0ck

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

#According to documentation, this should happen
s = pd.Series(range(5))
s.rolling(3).last()
0         NaN

Issue Description

What actually happens:

(Pdb) !s
0 0
1 1
2 2
3 3
4 4
dtype: int64
(Pdb) !s.rolling(3).last()
*** AttributeError: 'Rolling' object has no attribute 'last'
(Pdb) !s.rolling(3).first()
*** AttributeError: 'Rolling' object has no attribute 'first'
(Pdb)

(Pdb) pd.version
'2.2.1'

Expected Behavior

https://pandas.pydata.org/docs/dev/reference/api/pandas.core.window.rolling.Rolling.last.html

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

Installed Versions

Replace this line with the output of pd.show_versions()

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNeeds InfoClarification about behavior needed to assess issueWindowrolling, ewma, expanding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions