Skip to content

BUG: Sum on large integers incorrect after rolling timewindow #40043

Closed
@snthibaud

Description

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

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

    (optional) I have confirmed this bug exists on the master branch of pandas.


Code Sample, a copy-pastable example

import pandas as pd
from datetime import datetime, timedelta

s1 = pd.Series([138, 2377900603251717750], index=pd.Index([datetime(year=1970, month=1, day=1), datetime(year=1970, month=1, day=1)+timedelta(microseconds=1)]))
s2 = s1.rolling("1D").sum()
print(s2.sum() >= s1.sum())

Problem description

The sum of the rolling window should be higher or equal to the original series because only positive values are in it. However, 'False' is printed.

Expected Output

True

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit : 7d32926 python : 3.7.10.final.0 python-bits : 64 OS : Darwin OS-release : 20.3.0 Version : Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 machine : x86_64 processor : i386 byteorder : little LC_ALL : None LANG : None LOCALE : None.UTF-8 pandas : 1.2.2 numpy : 1.19.4 pytz : 2020.1 dateutil : 2.8.1 pip : 21.0.1 setuptools : 49.6.0.post20210108 Cython : None pytest : 6.2.2 hypothesis : 6.3.1 sphinx : None blosc : None feather : None xlsxwriter : None lxml.etree : 4.5.2 html5lib : None pymysql : 1.0.2 psycopg2 : None jinja2 : 2.11.2 IPython : 7.20.0 pandas_datareader: None bs4 : 4.7.1 bottleneck : None fsspec : None fastparquet : None gcsfs : None matplotlib : 3.2.2 numexpr : None odfpy : None openpyxl : 3.0.6 pandas_gbq : None pyarrow : 3.0.0 pyxlsb : None s3fs : None scipy : 1.6.0 sqlalchemy : 1.3.23 tables : None tabulate : None xarray : None xlrd : None xlwt : None numba : None

Activity

added
Needs TriageIssue that has not been reviewed by a pandas team member
on Feb 25, 2021
phofl

phofl commented on Feb 26, 2021

@phofl
Member

This is probably because this is internally cast to float, because the cython implementation expects floats.

This is probably a duplicate of #11446

added
Closing CandidateMay be closeable, needs more eyeballs
Windowrolling, ewma, expanding
and removed
Needs TriageIssue that has not been reviewed by a pandas team member
on Feb 26, 2021
phofl

phofl commented on Feb 27, 2021

@phofl
Member

closing as duplicate

added this to the No action milestone on Feb 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugClosing CandidateMay be closeable, needs more eyeballsDuplicate ReportDuplicate issue or pull requestWindowrolling, ewma, expanding

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @snthibaud@phofl

        Issue actions

          BUG: Sum on large integers incorrect after rolling timewindow · Issue #40043 · pandas-dev/pandas