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 df_time = pd.DataFrame({'B': [0, 1, 2, 4, 5, 6]}, index=[pd.Timestamp('20130101 09:00:00'), pd.Timestamp('20130101 09:00:02'), pd.Timestamp('20130101 09:00:03'), pd.Timestamp('20130101 09:00:06'), pd.Timestamp('20130101 09:00:07'), pd.Timestamp('20130101 09:00:08')]) sum1 = df_time.rolling('1s').sum() # micro seconds / milliseconds breaks the correct rolling! df_time.index = df_time.index.as_unit('us') sum2 = df_time.rolling('1s').sum() pd.testing.assert_frame_equal(sum1, sum2)
The rolling function returns incorrect values in case of the index isn't nano seconds.
Both sums should be identical
commit : 37ea63d python : 3.10.9.final.0 python-bits : 64 OS : Linux OS-release : 6.2.0-31-generic Version : #31~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Aug 16 13:45:26 UTC 2 machine : x86_64 processor : x86_64 byteorder : little LC_ALL : None LANG : en_IL LOCALE : en_IL.UTF-8 pandas : 2.0.1 numpy : 1.24.3 pytz : 2023.3 dateutil : 2.8.2 setuptools : 57.5.0 pip : 22.3.1 Cython : 3.0.0 pytest : 7.3.1 hypothesis : None sphinx : None blosc : None feather : None xlsxwriter : 3.1.2 lxml.etree : 4.9.3 html5lib : None pymysql : None psycopg2 : None jinja2 : 3.1.2 IPython : 8.14.0 pandas_datareader: None bs4 : 4.12.2 bottleneck : 1.3.7 brotli : 1.0.9 fastparquet : 2023.8.0 fsspec : 2023.6.0 gcsfs : 2023.6.0 matplotlib : 3.7.2 numba : 0.57.1 numexpr : 2.8.4 odfpy : None openpyxl : 3.1.2 pandas_gbq : 0.19.2 pyarrow : 12.0.1 pyreadstat : None pyxlsb : 1.0.10 s3fs : None scipy : 1.10.1 snappy : None sqlalchemy : None tables : 3.8.0 tabulate : None 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 tested this locally on 2.1.0 and can confirm it is a bug.
2.1.0
Sorry, something went wrong.
Note that on main branch, the usecase should be changed to:
import pandas as pd df_time = pd.DataFrame({'B': [0, 1, 2, 4, 5 ,6]}, index=[pd.Timestamp('20130101 09:00:00'), pd.Timestamp('20130101 09:00:02'), pd.Timestamp('20130101 09:00:03'), pd.Timestamp('20130101 09:00:06'), pd.Timestamp('20130101 09:00:07'), pd.Timestamp('20130101 09:00:08')]) sum1 = df_time.rolling('1s').sum() print(sum1) # micro seconds / milliseconds breaks the correct rolling! df_time.index = df_time.index.as_unit('us') sum2 = df_time.rolling('1s').sum() print(sum2) assert sum1.values == sum2.values
I'm going to fix it :)
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
The rolling function returns incorrect values in case of the index isn't nano seconds.
Expected Behavior
Both sums should be identical
Installed Versions
INSTALLED VERSIONS
commit : 37ea63d
python : 3.10.9.final.0
python-bits : 64
OS : Linux
OS-release : 6.2.0-31-generic
Version : #31~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Aug 16 13:45:26 UTC 2
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_IL
LOCALE : en_IL.UTF-8
pandas : 2.0.1
numpy : 1.24.3
pytz : 2023.3
dateutil : 2.8.2
setuptools : 57.5.0
pip : 22.3.1
Cython : 3.0.0
pytest : 7.3.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.1.2
lxml.etree : 4.9.3
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.14.0
pandas_datareader: None
bs4 : 4.12.2
bottleneck : 1.3.7
brotli : 1.0.9
fastparquet : 2023.8.0
fsspec : 2023.6.0
gcsfs : 2023.6.0
matplotlib : 3.7.2
numba : 0.57.1
numexpr : 2.8.4
odfpy : None
openpyxl : 3.1.2
pandas_gbq : 0.19.2
pyarrow : 12.0.1
pyreadstat : None
pyxlsb : 1.0.10
s3fs : None
scipy : 1.10.1
snappy : None
sqlalchemy : None
tables : 3.8.0
tabulate : None
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: