Skip to content

Commit 89bc204

Browse files
authored
CI/TST: Address TestArrowArray::test_reduce_series_numeric supporting skew (#61098)
1 parent 513e787 commit 89bc204

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
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:
@@ -168,4 +169,5 @@ def is_ci_environment() -> bool:
168169
"pa_version_under17p0",
169170
"pa_version_under18p0",
170171
"pa_version_under19p0",
172+
"pa_version_under20p0",
171173
]

pandas/tests/extension/test_arrow.py

+26-13
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
pa_version_under11p0,
4343
pa_version_under13p0,
4444
pa_version_under14p0,
45+
pa_version_under20p0,
4546
)
4647

4748
from pandas.core.dtypes.dtypes import (
@@ -453,31 +454,24 @@ def test_accumulate_series(self, data, all_numeric_accumulations, skipna, reques
453454
self.check_accumulate(ser, op_name, skipna)
454455

455456
def _supports_reduction(self, ser: pd.Series, op_name: str) -> bool:
456-
if op_name in ["kurt", "skew"]:
457+
if op_name == "kurt" or (pa_version_under20p0 and op_name == "skew"):
457458
return False
458459

459460
dtype = ser.dtype
460461
# error: Item "dtype[Any]" of "dtype[Any] | ExtensionDtype" has
461462
# no attribute "pyarrow_dtype"
462463
pa_dtype = dtype.pyarrow_dtype # type: ignore[union-attr]
463-
if pa.types.is_temporal(pa_dtype) and op_name in ["sum", "var", "prod"]:
464+
if pa.types.is_temporal(pa_dtype) and op_name in ["sum", "var", "prod", "skew"]:
464465
if pa.types.is_duration(pa_dtype) and op_name in ["sum"]:
465466
# summing timedeltas is one case that *is* well-defined
466467
pass
467468
else:
468469
return False
469-
elif pa.types.is_binary(pa_dtype) and op_name == "sum":
470+
elif pa.types.is_binary(pa_dtype) and op_name in ["sum", "skew"]:
470471
return False
471472
elif (
472473
pa.types.is_string(pa_dtype) or pa.types.is_binary(pa_dtype)
473-
) and op_name in [
474-
"mean",
475-
"median",
476-
"prod",
477-
"std",
478-
"sem",
479-
"var",
480-
]:
474+
) and op_name in ["mean", "median", "prod", "std", "sem", "var", "skew"]:
481475
return False
482476

483477
if (
@@ -561,7 +555,7 @@ def _get_expected_reduction_dtype(self, arr, op_name: str, skipna: bool):
561555
else:
562556
cmp_dtype = arr.dtype
563557
elif arr.dtype.name == "decimal128(7, 3)[pyarrow]":
564-
if op_name not in ["median", "var", "std", "sem"]:
558+
if op_name not in ["median", "var", "std", "sem", "skew"]:
565559
cmp_dtype = arr.dtype
566560
else:
567561
cmp_dtype = "float64[pyarrow]"
@@ -579,10 +573,29 @@ def _get_expected_reduction_dtype(self, arr, op_name: str, skipna: bool):
579573
}[arr.dtype.kind]
580574
return cmp_dtype
581575

576+
@pytest.mark.filterwarnings("ignore::RuntimeWarning")
577+
@pytest.mark.parametrize("skipna", [True, False])
578+
def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna, request):
579+
if (
580+
not pa_version_under20p0
581+
and skipna
582+
and all_numeric_reductions == "skew"
583+
and (
584+
pa.types.is_integer(data.dtype.pyarrow_dtype)
585+
or pa.types.is_floating(data.dtype.pyarrow_dtype)
586+
)
587+
):
588+
request.applymarker(
589+
pytest.mark.xfail(
590+
reason="https://github.com/apache/arrow/issues/45733",
591+
)
592+
)
593+
return super().test_reduce_series_numeric(data, all_numeric_reductions, skipna)
594+
582595
@pytest.mark.parametrize("skipna", [True, False])
583596
def test_reduce_frame(self, data, all_numeric_reductions, skipna, request):
584597
op_name = all_numeric_reductions
585-
if op_name == "skew":
598+
if op_name == "skew" and pa_version_under20p0:
586599
if data.dtype._is_numeric:
587600
mark = pytest.mark.xfail(reason="skew not implemented")
588601
request.applymarker(mark)

0 commit comments

Comments
 (0)