Skip to content

Commit cf242a2

Browse files
test ismethods
1 parent b9612fc commit cf242a2

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

pandas/tests/strings/test_strings.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,21 @@ def test_ismethods(method, expected, any_string_dtype):
217217
tm.assert_series_equal(result, expected)
218218

219219
# compare with standard library
220-
expected = [getattr(item, method)() for item in ser]
221-
assert list(result) == expected
220+
expected_stdlib = [getattr(item, method)() for item in ser]
221+
assert list(result) == expected_stdlib
222+
223+
# with missing value
224+
ser.iloc[[1, 2, 3, 4]] = np.nan
225+
result = getattr(ser.str, method)()
226+
if ser.dtype == "object":
227+
expected = expected.astype(object)
228+
expected.iloc[[1, 2, 3, 4]] = np.nan
229+
elif ser.dtype == "str":
230+
# NaN propagates as False
231+
expected.iloc[[1, 2, 3, 4]] = False
232+
else:
233+
# nullable dtypes propagate NaN
234+
expected.iloc[[1, 2, 3, 4]] = np.nan
222235

223236

224237
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)