MCPcopy
hub / github.com/pandas-dev/pandas / test_replace_callable

Function test_replace_callable

pandas/tests/strings/test_find_replace.py:639–647  ·  view source on GitHub ↗
(any_string_dtype)

Source from the content-addressed store, hash-verified

637
638
639def test_replace_callable(any_string_dtype):
640 # GH 15055
641 ser = Series(["fooBAD__barBAD", np.nan], dtype=any_string_dtype)
642
643 # test with callable
644 repl = lambda m: m.group(0).swapcase()
645 result = ser.str.replace("[a-z][A-Z]{2}", repl, n=2, regex=True)
646 expected = Series(["foObaD__baRbaD", np.nan], dtype=any_string_dtype)
647 tm.assert_series_equal(result, expected)
648
649
650@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 3

SeriesClass · 0.90
swapcaseMethod · 0.80
replaceMethod · 0.45

Tested by

no test coverage detected