4242 pa_version_under11p0 ,
4343 pa_version_under13p0 ,
4444 pa_version_under14p0 ,
45+ pa_version_under20p0 ,
4546)
4647
4748from 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