Skip to content

Commit ecf5061

Browse files
simonjayhawkinsvladu
authored andcommitted
[ArrowStringArray] add dtype parameterisation to test_astype_float and test_fillna_args (pandas-dev#40677)
1 parent 823d888 commit ecf5061

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

pandas/tests/arrays/string_/test_string.py

+25-6
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,20 @@ def test_astype_int(dtype, request):
364364
tm.assert_extension_array_equal(result, expected)
365365

366366

367-
def test_astype_float(any_float_allowed_nullable_dtype):
367+
def test_astype_float(dtype, any_float_allowed_nullable_dtype, request):
368368
# Don't compare arrays (37974)
369-
ser = pd.Series(["1.1", pd.NA, "3.3"], dtype="string")
369+
370+
if dtype == "arrow_string":
371+
if any_float_allowed_nullable_dtype in {"Float32", "Float64"}:
372+
reason = "TypeError: Cannot interpret 'Float32Dtype()' as a data type"
373+
else:
374+
reason = (
375+
"TypeError: float() argument must be a string or a number, not 'NAType'"
376+
)
377+
mark = pytest.mark.xfail(reason=reason)
378+
request.node.add_marker(mark)
379+
380+
ser = pd.Series(["1.1", pd.NA, "3.3"], dtype=dtype)
370381

371382
result = ser.astype(any_float_allowed_nullable_dtype)
372383
expected = pd.Series([1.1, np.nan, 3.3], dtype=any_float_allowed_nullable_dtype)
@@ -429,17 +440,25 @@ def test_reduce_missing(skipna, dtype):
429440
assert pd.isna(result)
430441

431442

432-
def test_fillna_args():
443+
def test_fillna_args(dtype, request):
433444
# GH 37987
434445

435-
arr = pd.array(["a", pd.NA], dtype="string")
446+
if dtype == "arrow_string":
447+
reason = (
448+
"AssertionError: Regex pattern \"Cannot set non-string value '1' into "
449+
"a StringArray.\" does not match 'Scalar must be NA or str'"
450+
)
451+
mark = pytest.mark.xfail(reason=reason)
452+
request.node.add_marker(mark)
453+
454+
arr = pd.array(["a", pd.NA], dtype=dtype)
436455

437456
res = arr.fillna(value="b")
438-
expected = pd.array(["a", "b"], dtype="string")
457+
expected = pd.array(["a", "b"], dtype=dtype)
439458
tm.assert_extension_array_equal(res, expected)
440459

441460
res = arr.fillna(value=np.str_("b"))
442-
expected = pd.array(["a", "b"], dtype="string")
461+
expected = pd.array(["a", "b"], dtype=dtype)
443462
tm.assert_extension_array_equal(res, expected)
444463

445464
msg = "Cannot set non-string value '1' into a StringArray."

0 commit comments

Comments
 (0)