42
42
pa_version_under11p0 ,
43
43
pa_version_under13p0 ,
44
44
pa_version_under14p0 ,
45
+ pa_version_under20p0 ,
45
46
)
46
47
47
48
from pandas .core .dtypes .dtypes import (
@@ -453,31 +454,24 @@ def test_accumulate_series(self, data, all_numeric_accumulations, skipna, reques
453
454
self .check_accumulate (ser , op_name , skipna )
454
455
455
456
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" ) :
457
458
return False
458
459
459
460
dtype = ser .dtype
460
461
# error: Item "dtype[Any]" of "dtype[Any] | ExtensionDtype" has
461
462
# no attribute "pyarrow_dtype"
462
463
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" ]:
464
465
if pa .types .is_duration (pa_dtype ) and op_name in ["sum" ]:
465
466
# summing timedeltas is one case that *is* well-defined
466
467
pass
467
468
else :
468
469
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" ] :
470
471
return False
471
472
elif (
472
473
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" ]:
481
475
return False
482
476
483
477
if (
@@ -561,7 +555,7 @@ def _get_expected_reduction_dtype(self, arr, op_name: str, skipna: bool):
561
555
else :
562
556
cmp_dtype = arr .dtype
563
557
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" ]:
565
559
cmp_dtype = arr .dtype
566
560
else :
567
561
cmp_dtype = "float64[pyarrow]"
@@ -579,10 +573,29 @@ def _get_expected_reduction_dtype(self, arr, op_name: str, skipna: bool):
579
573
}[arr .dtype .kind ]
580
574
return cmp_dtype
581
575
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
+
582
595
@pytest .mark .parametrize ("skipna" , [True , False ])
583
596
def test_reduce_frame (self , data , all_numeric_reductions , skipna , request ):
584
597
op_name = all_numeric_reductions
585
- if op_name == "skew" :
598
+ if op_name == "skew" and pa_version_under20p0 :
586
599
if data .dtype ._is_numeric :
587
600
mark = pytest .mark .xfail (reason = "skew not implemented" )
588
601
request .applymarker (mark )
0 commit comments