Skip to content

TST: update expected dtype for sum of decimals with pyarrow 21+ #61799

New issue

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
pa_version_under18p0,
pa_version_under19p0,
pa_version_under20p0,
pa_version_under21p0,
)

if TYPE_CHECKING:
Expand Down Expand Up @@ -168,4 +169,5 @@ def is_ci_environment() -> bool:
"pa_version_under18p0",
"pa_version_under19p0",
"pa_version_under20p0",
"pa_version_under21p0",
]
2 changes: 2 additions & 0 deletions pandas/compat/pyarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
pa_version_under18p0 = _palv < Version("18.0.0")
pa_version_under19p0 = _palv < Version("19.0.0")
pa_version_under20p0 = _palv < Version("20.0.0")
pa_version_under21p0 = _palv < Version("21.0.0")
HAS_PYARROW = _palv >= Version("12.0.1")
except ImportError:
pa_version_under12p1 = True
Expand All @@ -30,4 +31,5 @@
pa_version_under18p0 = True
pa_version_under19p0 = True
pa_version_under20p0 = True
pa_version_under21p0 = True
HAS_PYARROW = False
6 changes: 5 additions & 1 deletion pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
pa_version_under14p0,
pa_version_under19p0,
pa_version_under20p0,
pa_version_under21p0,
)

from pandas.core.dtypes.dtypes import (
Expand Down Expand Up @@ -542,7 +543,10 @@ def _get_expected_reduction_dtype(self, arr, op_name: str, skipna: bool):
else:
cmp_dtype = arr.dtype
elif arr.dtype.name == "decimal128(7, 3)[pyarrow]":
if op_name not in ["median", "var", "std", "sem", "skew"]:
if op_name == "sum" and not pa_version_under21p0:
# https://github.com/apache/arrow/pull/44184
cmp_dtype = ArrowDtype(pa.decimal128(38, 3))
elif op_name not in ["median", "var", "std", "sem", "skew"]:
cmp_dtype = arr.dtype
else:
cmp_dtype = "float64[pyarrow]"
Expand Down
Loading