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
Prev Previous commit
Next Next commit
Review (WillAyd)
  • Loading branch information
h-vetinari committed Oct 11, 2018
commit 0d3c6d21ed9f262acd712072a4bcde12329b51df
3 changes: 0 additions & 3 deletions pandas/core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,6 @@ def cat_core(list_of_columns, sep):
nd.array
The concatenation of list_of_columns with sep
"""
if sep == '':
# no need to add empty strings
return np.sum(list_of_columns, axis=0)
list_with_sep = [sep] * (2 * len(list_of_columns) - 1)
list_with_sep[::2] = list_of_columns
return np.sum(list_with_sep, axis=0)
Expand Down
8 changes: 7 additions & 1 deletion pandas/tests/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,12 @@ def test_str_cat_align_mixed_inputs(self, join):
with tm.assert_raises_regex(ValueError, rgx):
s.str.cat([t, z], join=join)

def test_str_cat_raises(self):
# non-strings hiding behind object dtype
s = Series([1, 2, 3, 4], dtype='object')
with tm.assert_raises_regex(TypeError, "unsupported operand type.*"):
s.str.cat(s)

def test_str_cat_special_cases(self):
s = Series(['a', 'b', 'c', 'd'])
t = Series(['d', 'a', 'e', 'b'], index=[3, 0, 4, 1])
Expand Down Expand Up @@ -3089,7 +3095,7 @@ def test_method_on_bytes(self):
lhs = Series(np.array(list('abc'), 'S1').astype(object))
rhs = Series(np.array(list('def'), 'S1').astype(object))
if compat.PY3:
pytest.raises(TypeError, lhs.str.cat, rhs, sep=',')
pytest.raises(TypeError, lhs.str.cat, rhs)
else:
result = lhs.str.cat(rhs)
expected = Series(np.array(
Expand Down