77import numpy as np
88import pytest
99
10+ from pandas .compat import pa_version_under21p0
1011from pandas .errors import Pandas4Warning
1112
1213from pandas import (
1516 Index ,
1617 MultiIndex ,
1718 Series ,
19+ StringDtype ,
1820 option_context ,
1921)
2022import pandas ._testing as tm
@@ -249,8 +251,9 @@ def test_ismethods(method, expected, any_string_dtype):
249251@pytest .mark .parametrize (
250252 "method, expected" ,
251253 [
252- ("isnumeric" , [False , True , True , False , True , True , False ]),
253- ("isdecimal" , [False , True , False , False , False , True , False ]),
254+ ("isnumeric" , [False , True , True , True , False , True , True , False ]),
255+ ("isdecimal" , [False , True , False , False , False , False , True , False ]),
256+ ("isdigit" , [False , True , True , False , False , False , True , False ]),
254257 ],
255258)
256259def test_isnumeric_unicode (method , expected , any_string_dtype ):
@@ -259,19 +262,35 @@ def test_isnumeric_unicode(method, expected, any_string_dtype):
259262 # 0x1378: ፸ ETHIOPIC NUMBER SEVENTY
260263 # 0xFF13: 3 Em 3 # noqa: RUF003
261264 ser = Series (
262- ["A" , "3" , "¼" , "★" , "፸" , "3" , "four" ], # noqa: RUF001
265+ ["A" , "3" , "³" , " ¼" , "★" , "፸" , "3" , "four" ], # noqa: RUF001
263266 dtype = any_string_dtype ,
264267 )
265268 expected_dtype = (
266269 "bool" if is_object_or_nan_string_dtype (any_string_dtype ) else "boolean"
267270 )
268271 expected = Series (expected , dtype = expected_dtype )
272+ if (
273+ method == "isdigit"
274+ and isinstance (ser .dtype , StringDtype )
275+ and ser .dtype .storage == "pyarrow"
276+ and not pa_version_under21p0
277+ ):
278+ # known difference in behavior between python and pyarrow unicode handling
279+ # pyarrow 21+ considers ¼ and ፸ as a digit, while python does not
280+ expected .iloc [3 ] = True
281+ expected .iloc [5 ] = True
282+
269283 result = getattr (ser .str , method )()
270284 tm .assert_series_equal (result , expected )
271285
272286 # compare with standard library
273- expected = [getattr (item , method )() for item in ser ]
274- assert list (result ) == expected
287+ # (only for non-pyarrow storage given the above differences)
288+ if any_string_dtype == "object" or (
289+ isinstance (any_string_dtype , StringDtype )
290+ and any_string_dtype .storage == "python"
291+ ):
292+ expected = [getattr (item , method )() for item in ser ]
293+ assert list (result ) == expected
275294
276295
277296@pytest .mark .parametrize (
0 commit comments