Description
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
import pandas as pd
import decimal
import pyarrow as pa
d = {'year': ["2010", "2011", "2012", "2013", "2014"], 'value': [pd.NA, decimal.Decimal('2.0'), decimal.Decimal('3.0'), decimal.Decimal('4.0'), decimal.Decimal('5.0')]}
df = pd.DataFrame(data=d)
df["value"] = df["value"].astype(pd.ArrowDtype(pa.decimal128(2,1)))
df.groupby('year').sum(min_count=1, numeric_only=False)
"""
value
year
2010 0.0 <-- expected <NA>
2011 2.0
2012 3.0
2013 4.0
2014 5.0
"""
Issue Description
DataFrameGroupBy.sum does not respect arguments min_count
and numeric_only
for PyArrow decimal, even though it should. I tried all combinations of these two arguments, and NONE of them produced the expected result.
Note that I tried different aggregations – min, max, mean, and median, and all of them worked properly. Producing the following result.
value
year
2010 <NA>
2011 2.0
2012 3.0
2013 4.0
2014 5.0
Expected Behavior
I expect it to behave the same as for different aggregations mentioned above.
Expected result is
value
year
2010 <NA>
2011 2.0
2012 3.0
2013 4.0
2014 5.0
Installed Versions
INSTALLED VERSIONS
commit : a60ad39
python : 3.11.4.final.0
python-bits : 64
OS : Darwin
OS-release : 23.1.0
Version : Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : None
LOCALE : None.UTF-8
pandas : 2.1.2
numpy : 1.26.1
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 65.5.0
pip : 23.1.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : 8.17.2
pandas_datareader : None
bs4 : None
bottleneck : None
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : 13.0.0
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None