Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix 28277
  • Loading branch information
xr-chen committed Jul 16, 2022
commit 16280b6bfaff89cbb42bd72c16e02424ad5b77df
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` when ``others`` is a ``Series.str`` object, only concating longest string (: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)
expected = Series(["AbCAbC", "dede", "FGHIFGHI", "jj", "kLLLmkLLLm"])
tm.assert_series_equal(res, expected)