Skip to content

Commit e89f94a

Browse files
committed
Backport PR pandas-dev#61098: CI/TST: Address TestArrowArray::test_reduce_series_numeric supporting skew
1 parent 9857d31 commit e89f94a

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

pandas/compat/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
pa_version_under17p0,
3636
pa_version_under18p0,
3737
pa_version_under19p0,
38+
pa_version_under20p0,
3839
)
3940

4041
if TYPE_CHECKING:
@@ -195,6 +196,7 @@ def get_bz2_file() -> type[pandas.compat.compressors.BZ2File]:
195196
"pa_version_under17p0",
196197
"pa_version_under18p0",
197198
"pa_version_under19p0",
199+
"pa_version_under20p0",
198200
"HAS_PYARROW",
199201
"IS64",
200202
"ISMUSL",

pandas/tests/extension/test_arrow.py

+21-3
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
pa_version_under11p0,
4141
pa_version_under13p0,
4242
pa_version_under14p0,
43+
pa_version_under20p0,
4344
)
4445

4546
from pandas.core.dtypes.dtypes import (
@@ -448,6 +449,9 @@ def test_accumulate_series(self, data, all_numeric_accumulations, skipna, reques
448449
self.check_accumulate(ser, op_name, skipna)
449450

450451
def _supports_reduction(self, ser: pd.Series, op_name: str) -> bool:
452+
if op_name == "kurt" or (pa_version_under20p0 and op_name == "skew"):
453+
return False
454+
451455
dtype = ser.dtype
452456
# error: Item "dtype[Any]" of "dtype[Any] | ExtensionDtype" has
453457
# no attribute "pyarrow_dtype"
@@ -464,7 +468,7 @@ def _supports_reduction(self, ser: pd.Series, op_name: str) -> bool:
464468
pass
465469
else:
466470
return False
467-
elif pa.types.is_binary(pa_dtype) and op_name == "sum":
471+
elif pa.types.is_binary(pa_dtype) and op_name in ["sum", "skew"]:
468472
return False
469473
elif (
470474
pa.types.is_string(pa_dtype) or pa.types.is_binary(pa_dtype)
@@ -537,6 +541,20 @@ def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna, reque
537541
"median",
538542
}:
539543
request.applymarker(xfail_mark)
544+
elif (
545+
not pa_version_under20p0
546+
and skipna
547+
and all_numeric_reductions == "skew"
548+
and (
549+
pa.types.is_integer(data.dtype.pyarrow_dtype)
550+
or pa.types.is_floating(data.dtype.pyarrow_dtype)
551+
)
552+
):
553+
request.applymarker(
554+
pytest.mark.xfail(
555+
reason="https://github.com/apache/arrow/issues/45733",
556+
)
557+
)
540558
super().test_reduce_series_numeric(data, all_numeric_reductions, skipna)
541559

542560
@pytest.mark.parametrize("skipna", [True, False])
@@ -563,7 +581,7 @@ def _get_expected_reduction_dtype(self, arr, op_name: str, skipna: bool):
563581
if op_name in ["max", "min"]:
564582
cmp_dtype = arr.dtype
565583
elif arr.dtype.name == "decimal128(7, 3)[pyarrow]":
566-
if op_name not in ["median", "var", "std"]:
584+
if op_name not in ["median", "var", "std", "skew"]:
567585
cmp_dtype = arr.dtype
568586
else:
569587
cmp_dtype = "float64[pyarrow]"
@@ -582,7 +600,7 @@ def _get_expected_reduction_dtype(self, arr, op_name: str, skipna: bool):
582600
@pytest.mark.parametrize("skipna", [True, False])
583601
def test_reduce_frame(self, data, all_numeric_reductions, skipna, request):
584602
op_name = all_numeric_reductions
585-
if op_name == "skew":
603+
if op_name == "skew" and pa_version_under20p0:
586604
if data.dtype._is_numeric:
587605
mark = pytest.mark.xfail(reason="skew not implemented")
588606
request.applymarker(mark)

0 commit comments

Comments
 (0)