File tree 2 files changed +25
-5
lines changed
2 files changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -527,11 +527,7 @@ def _box_pa_array(
527
527
else :
528
528
try :
529
529
pa_array = pa_array .cast (pa_type )
530
- except (
531
- pa .ArrowInvalid ,
532
- pa .ArrowTypeError ,
533
- pa .ArrowNotImplementedError ,
534
- ):
530
+ except (pa .ArrowNotImplementedError , pa .ArrowTypeError ):
535
531
if pa .types .is_string (pa_array .type ) or pa .types .is_large_string (
536
532
pa_array .type
537
533
):
Original file line number Diff line number Diff line change @@ -3203,6 +3203,30 @@ def test_pow_missing_operand():
3203
3203
tm .assert_series_equal (result , expected )
3204
3204
3205
3205
3206
+ @pytest .mark .skipif (
3207
+ pa_version_under11p0 , reason = "Decimal128 to string cast implemented in pyarrow 11"
3208
+ )
3209
+ def test_decimal_parse_raises ():
3210
+ # GH 56984
3211
+ ser = pd .Series (["1.2345" ], dtype = ArrowDtype (pa .string ()))
3212
+ with pytest .raises (
3213
+ pa .lib .ArrowInvalid , match = "Rescaling Decimal128 value would cause data loss"
3214
+ ):
3215
+ ser .astype (ArrowDtype (pa .decimal128 (1 , 0 )))
3216
+
3217
+
3218
+ @pytest .mark .skipif (
3219
+ pa_version_under11p0 , reason = "Decimal128 to string cast implemented in pyarrow 11"
3220
+ )
3221
+ def test_decimal_parse_succeeds ():
3222
+ # GH 56984
3223
+ ser = pd .Series (["1.2345" ], dtype = ArrowDtype (pa .string ()))
3224
+ dtype = ArrowDtype (pa .decimal128 (5 , 4 ))
3225
+ result = ser .astype (dtype )
3226
+ expected = pd .Series ([Decimal ("1.2345" )], dtype = dtype )
3227
+ tm .assert_series_equal (result , expected )
3228
+
3229
+
3206
3230
@pytest .mark .parametrize ("pa_type" , tm .TIMEDELTA_PYARROW_DTYPES )
3207
3231
def test_duration_fillna_numpy (pa_type ):
3208
3232
# GH 54707
You can’t perform that action at this time.
0 commit comments