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
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.5.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -866,6 +866,7 @@ Strings
^^^^^^^
- Bug in :meth:`str.startswith` and :meth:`str.endswith` when using other series as parameter _pat_. Now raises ``TypeError`` (:issue:`3485`)
- Bug in :meth:`Series.str.zfill` when strings contain leading signs, padding '0' before the sign character rather than after as ``str.zfill`` from standard library (:issue:`20868`)
- Bug in :meth:`Series.str.cat` only concatenating the longest string when ``others`` is a ``Series.str`` object (:issue:`28277`)
-

Interval
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/strings/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,8 @@ def _get_series_list(self, others):
elif isinstance(others, np.ndarray) and others.ndim == 2:
others = DataFrame(others, index=idx)
return [others[x] for x in others]
elif isinstance(others, type(self)):
return [others._data]
elif is_list_like(others, allow_sets=False):
others = list(others) # ensure iterators do not get read twice etc

Expand Down
8 changes: 8 additions & 0 deletions pandas/tests/strings/test_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,3 +376,11 @@ 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():
ps = Series(["AbC", "de", "FGHI", "j", "kLLLm"])

res = ps.str.cat(others=ps.str)
mroeschke marked this conversation as resolved.
Show resolved Hide resolved
expected = Series(["AbCAbC", "dede", "FGHIFGHI", "jj", "kLLLmkLLLm"])
tm.assert_series_equal(res, expected)