Pandas version checks
-
[x] I have checked that this issue has not already been reported.
-
[x] I have confirmed this bug exists on the latest version of pandas.
-
[x] 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
Comment From: rhshadrach
Thanks for the report. Can you post the output of pd.show_versions()
as requested in our issue template. Closing until further information is provided.
Comment From: k0ck
Thanks for the response. The following is my local m1. I see the same bug on google colab as well
INSTALLED VERSIONS
commit : bdc79c146c2e32f2cab629be240f01658cfb6cc2 python : 3.11.11.final.0 python-bits : 64 OS : Darwin OS-release : 24.4.0 Version : Darwin Kernel Version 24.4.0: Fri Apr 11 18:32:43 PDT 2025; root:xnu-11417.101.15~117/RELEASE_ARM64_T8103 machine : arm64 processor : i386 byteorder : little LC_ALL : None LANG : en_US.UTF-8 LOCALE : en_US.UTF-8
pandas : 2.2.1 numpy : 1.26.4 pytz : 2025.2 dateutil : 2.9.0.post0 setuptools : 67.6.1 pip : 25.2 Cython : None pytest : 8.3.3 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : 5.2.2 html5lib : 1.1 pymysql : None psycopg2 : 2.9.9 jinja2 : 3.1.4 IPython : 8.25.0 pandas_datareader : None adbc-driver-postgresql: None adbc-driver-sqlite : None bs4 : 4.12.3 bottleneck : None dataframe-api-compat : None fastparquet : None fsspec : 2024.3.1 gcsfs : None matplotlib : 3.9.0 numba : 0.61.2 numexpr : None odfpy : None openpyxl : None pandas_gbq : None pyarrow : 15.0.2 pyreadstat : None python-calamine : None pyxlsb : None s3fs : None scipy : 1.12.0 sqlalchemy : 2.0.29 tables : None tabulate : 0.9.0 xarray : None xlrd : None zstandard : None tzdata : 2025.2 qtpy : None pyqt5 : None
Comment From: Alvaro-Kothe
https://pandas.pydata.org/docs/dev/reference/api/pandas.core.window.rolling.Rolling.last.html
These are the docs for the development version. This method was introduced on #60579 (for version 3).