Description
-
[ 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.
-
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
import pandas as pd
for i in range(100):
n = 2 ** i
print(f"Trying n = 2 ** {i} '{n}'...")
df = pd.DataFrame([['A', 14], ['A', n]], columns=['gb', 'val'])
gb_sum = df.groupby('gb').sum().values[0][0]
df_sum = df.sum().values[1]
if gb_sum != df_sum:
print(f"df.sum().values[1] '{df_sum}' != df.groupby('gb').sum().values[0][0] '{gb_sum}")
break
del df
print(f"Runing pandas {pd.__version__}")
Problem description
groupby.sum() results currently provide different results for df.sum() results for large integers.
It is expected that they should provide the same results.
Expected Output
When grouping by a colum with a single value, the groupby().sum() result should always equal the df.sum() result()
Output of pd.show_versions()
INSTALLED VERSIONS
commit : None
python : 3.7.7.final.0
python-bits : 64
OS : Darwin
OS-release : 19.5.0
machine : x86_64
processor : i386
byteorder : little
LC_ALL : None
LANG : None
LOCALE : en_US.UTF-8
pandas : 1.0.4
numpy : 1.18.2
pytz : 2019.3
dateutil : 2.8.1
pip : 19.0.3
setuptools : 40.8.0
Cython : 0.29.16
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : 2.8.3 (dt dec pq3 ext lo64)
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : 2.6.2
pandas_gbq : None
pyarrow : None
pytables : None
pytest : None
pyxlsb : None
s3fs : 0.4.2
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : 1.2.0
xlwt : None
xlsxwriter : None
numba : None
Runing pandas None
Process finished with exit code 0