Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: Add additional test for future warning when call Series.str.cat(Series.str) #47755

Merged
merged 5 commits into from
Jul 19, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions pandas/tests/strings/test_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,22 @@ def test_cat_different_classes(klass):
result = s.str.cat(klass(["x", "y", "z"]))
expected = Series(["ax", "by", "cz"])
tm.assert_series_equal(result, expected)


def test_cat_on_series_dot_str():
# GH 28277
# Test future warning of `Series.str.__iter__`
ps = Series(["AbC", "de", "FGHI", "j", "kLLLm"])
with tm.assert_produces_warning(FutureWarning):
ps.str.cat(others=ps.str)
# The following code will be uncommented if `Series.str.__iter__` is removed.
xr-chen marked this conversation as resolved.
Show resolved Hide resolved
"""
message = re.escape(
mroeschke marked this conversation as resolved.
Show resolved Hide resolved
"others must be Series, Index, DataFrame, np.ndarray "
"or list-like (either containing only strings or "
"containing only objects of type Series/Index/"
"np.ndarray[1-dim])"
)
with pytest.raises(TypeError, match=message):
ps.str.cat(others=ps.str)
"""