We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
import pandas as pd index = ['2019-01-03 05:11', '2019-01-03 05:23', '2019-01-03 05:28', '2019-01-03 05:32', '2019-01-03 05:36'] arr= [True, False, False, True, True] df = pd.DataFrame({'arr': arr}, index=pd.to_datetime(index).astype('datetime64[us]')) print(df.rolling('5min').sum()) arr 2019-01-03 05:11:00 1.0 2019-01-03 05:23:00 1.0 2019-01-03 05:28:00 1.0 2019-01-03 05:32:00 2.0 2019-01-03 05:36:00 3.0
df = pd.DataFrame({'arr': arr}, index=pd.to_datetime(index).astype('datetime64[ms]')) print(df.rolling('5min').sum()) arr 2019-01-03 05:11:00 1.0 2019-01-03 05:23:00 1.0 2019-01-03 05:28:00 1.0 2019-01-03 05:32:00 2.0 2019-01-03 05:36:00 3.0
Output of rolling window operations for timeseries such as sum or count is wrong when the index is of type is not 'datetime64[ns]'.
df = pd.DataFrame({'arr': arr}, index=pd.to_datetime(index).astype('datetime64[ns]')) print(df.rolling('5min').sum()) arr 2019-01-03 05:11:00 1.0 2019-01-03 05:23:00 0.0 2019-01-03 05:28:00 0.0 2019-01-03 05:32:00 1.0 2019-01-03 05:36:00 2.0
commit : e86ed37 python : 3.10.12.final.0 python-bits : 64 OS : Linux OS-release : 5.15.120+ Version : #1 SMP Wed Aug 30 11:19:59 UTC 2023 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : en_US.UTF-8 LANG : en_US.UTF-8 LOCALE : en_US.UTF-8
pandas : 2.1.1 numpy : 1.23.5 pytz : 2023.3.post1 dateutil : 2.8.2 setuptools : 67.7.2 pip : 23.1.2 Cython : 3.0.2 pytest : 7.4.1 hypothesis : None sphinx : 5.0.2 blosc : None feather : None xlsxwriter : None lxml.etree : 4.9.3 html5lib : 1.1 pymysql : None psycopg2 : 2.9.7 jinja2 : 3.1.2 IPython : 7.34.0 pandas_datareader : 0.10.0 bs4 : 4.11.2 bottleneck : None dataframe-api-compat: None fastparquet : None fsspec : 2023.6.0 gcsfs : 2023.6.0 matplotlib : 3.7.1 numba : 0.56.4 numexpr : 2.8.5 odfpy : None openpyxl : 3.1.2 pandas_gbq : 0.17.9 pyarrow : 9.0.0 pyreadstat : None pyxlsb : None s3fs : None scipy : 1.11.2 sqlalchemy : 2.0.20 tables : 3.8.0 tabulate : 0.9.0 xarray : 2023.7.0 xlrd : 2.0.1 zstandard : None tzdata : 2023.3 qtpy : None pyqt5 : None
The text was updated successfully, but these errors were encountered:
I can confirm that the bug exists on the main development branch of pandas.
Would you mind updating your test case to use 5min in rolling instead of 5T since T is being deprecated?
5min
rolling
5T
T
It would also be helpful if you added the current output for the datetime64[us] version:
datetime64[us]
>>> print(df.rolling('5min').sum()) arr 2019-01-03 05:11:00 1.0 2019-01-03 05:23:00 1.0 2019-01-03 05:28:00 1.0 2019-01-03 05:32:00 2.0 2019-01-03 05:36:00 3.0
Sorry, something went wrong.
take
I've reproduced this locally and have a fix. I'll submit a PR after some cleanup and testing.
Thanks for the report. Closing as duplicate of #55106
banorton
Successfully merging a pull request may close this issue.
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
Issue Description
Output of rolling window operations for timeseries such as sum or count is wrong when the index is of type is not 'datetime64[ns]'.
Expected Behavior
Installed Versions
INSTALLED VERSIONS
commit : e86ed37
python : 3.10.12.final.0
python-bits : 64
OS : Linux
OS-release : 5.15.120+
Version : #1 SMP Wed Aug 30 11:19:59 UTC 2023
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : en_US.UTF-8
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 2.1.1
numpy : 1.23.5
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 67.7.2
pip : 23.1.2
Cython : 3.0.2
pytest : 7.4.1
hypothesis : None
sphinx : 5.0.2
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.3
html5lib : 1.1
pymysql : None
psycopg2 : 2.9.7
jinja2 : 3.1.2
IPython : 7.34.0
pandas_datareader : 0.10.0
bs4 : 4.11.2
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : 2023.6.0
gcsfs : 2023.6.0
matplotlib : 3.7.1
numba : 0.56.4
numexpr : 2.8.5
odfpy : None
openpyxl : 3.1.2
pandas_gbq : 0.17.9
pyarrow : 9.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.11.2
sqlalchemy : 2.0.20
tables : 3.8.0
tabulate : 0.9.0
xarray : 2023.7.0
xlrd : 2.0.1
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: