40
40
pa_version_under11p0 ,
41
41
pa_version_under13p0 ,
42
42
pa_version_under14p0 ,
43
+ pa_version_under20p0 ,
43
44
)
44
45
45
46
from pandas .core .dtypes .dtypes import (
@@ -448,6 +449,9 @@ def test_accumulate_series(self, data, all_numeric_accumulations, skipna, reques
448
449
self .check_accumulate (ser , op_name , skipna )
449
450
450
451
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
+
451
455
dtype = ser .dtype
452
456
# error: Item "dtype[Any]" of "dtype[Any] | ExtensionDtype" has
453
457
# no attribute "pyarrow_dtype"
@@ -464,7 +468,7 @@ def _supports_reduction(self, ser: pd.Series, op_name: str) -> bool:
464
468
pass
465
469
else :
466
470
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" ] :
468
472
return False
469
473
elif (
470
474
pa .types .is_string (pa_dtype ) or pa .types .is_binary (pa_dtype )
@@ -525,18 +529,31 @@ def test_reduce_series_numeric(self, data, all_numeric_reductions, skipna, reque
525
529
f"pyarrow={ pa .__version__ } for { pa_dtype } "
526
530
),
527
531
)
528
- if all_numeric_reductions in {"skew" , "kurt" } and (
529
- dtype ._is_numeric or dtype .kind == "b"
530
- ):
531
- request .applymarker (xfail_mark )
532
-
533
- elif pa .types .is_boolean (pa_dtype ) and all_numeric_reductions in {
532
+ if pa .types .is_boolean (pa_dtype ) and all_numeric_reductions in {
534
533
"sem" ,
535
534
"std" ,
536
535
"var" ,
537
536
"median" ,
538
537
}:
539
538
request .applymarker (xfail_mark )
539
+ elif (
540
+ not pa_version_under20p0
541
+ and all_numeric_reductions == "skew"
542
+ and (
543
+ pa .types .is_boolean (pa_dtype )
544
+ or (
545
+ skipna
546
+ and (
547
+ pa .types .is_integer (pa_dtype ) or pa .types .is_floating (pa_dtype )
548
+ )
549
+ )
550
+ )
551
+ ):
552
+ request .applymarker (
553
+ pytest .mark .xfail (
554
+ reason = "https://github.com/apache/arrow/issues/45733" ,
555
+ )
556
+ )
540
557
super ().test_reduce_series_numeric (data , all_numeric_reductions , skipna )
541
558
542
559
@pytest .mark .parametrize ("skipna" , [True , False ])
@@ -563,7 +580,7 @@ def _get_expected_reduction_dtype(self, arr, op_name: str, skipna: bool):
563
580
if op_name in ["max" , "min" ]:
564
581
cmp_dtype = arr .dtype
565
582
elif arr .dtype .name == "decimal128(7, 3)[pyarrow]" :
566
- if op_name not in ["median" , "var" , "std" ]:
583
+ if op_name not in ["median" , "var" , "std" , "skew" ]:
567
584
cmp_dtype = arr .dtype
568
585
else :
569
586
cmp_dtype = "float64[pyarrow]"
@@ -582,7 +599,7 @@ def _get_expected_reduction_dtype(self, arr, op_name: str, skipna: bool):
582
599
@pytest .mark .parametrize ("skipna" , [True , False ])
583
600
def test_reduce_frame (self , data , all_numeric_reductions , skipna , request ):
584
601
op_name = all_numeric_reductions
585
- if op_name == "skew" :
602
+ if op_name == "skew" and pa_version_under20p0 :
586
603
if data .dtype ._is_numeric :
587
604
mark = pytest .mark .xfail (reason = "skew not implemented" )
588
605
request .applymarker (mark )
0 commit comments