File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -439,6 +439,10 @@ def _cast_pointwise_result(self, values) -> ArrayLike:
439439 # or test_agg_lambda_complex128_dtype_conversion for complex values
440440 return super ()._cast_pointwise_result (values )
441441
442+ if pa .types .is_null (arr .type ):
443+ if lib .infer_dtype (values ) == "decimal" :
444+ # GH#62522; the specific decimal precision here is arbitrary
445+ arr = arr .cast (pa .decimal128 (1 ))
442446 if pa .types .is_duration (arr .type ):
443447 # workaround for https://github.com/apache/arrow/issues/40620
444448 result = ArrowExtensionArray ._from_sequence (values )
Original file line number Diff line number Diff line change @@ -3700,3 +3700,15 @@ def test_pow_with_all_na_float():
37003700 result = s .pow (2 )
37013701 expected = pd .Series ([pd .NA , pd .NA ], dtype = "float64[pyarrow]" )
37023702 tm .assert_series_equal (result , expected )
3703+
3704+
3705+ def test_cast_pontwise_result_decimal_nan ():
3706+ # GH#62522 we don't want to get back null[pyarrow] here
3707+ ser = pd .Series ([], dtype = "float64[pyarrow]" )
3708+ arr = ser .array
3709+ item = Decimal ("NaN" )
3710+
3711+ result = arr ._cast_pointwise_result ([item ])
3712+
3713+ pa_type = result .dtype .pyarrow_dtype
3714+ assert pa .types .is_decimal (pa_type )
You can’t perform that action at this time.
0 commit comments