Skip to content

Commit c046dfb

Browse files
h-vetinarijreback
authored andcommitted
PERF: Add if branch for empty sep in str.cat (#26605)
1 parent 5919f9d commit c046dfb

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

pandas/core/strings.py

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ def cat_core(list_of_columns: List, sep: str):
5959
nd.array
6060
The concatenation of list_of_columns with sep
6161
"""
62+
if sep == "":
63+
# no need to interleave sep if it is empty
64+
return np.sum(list_of_columns, axis=0)
6265
list_with_sep = [sep] * (2 * len(list_of_columns) - 1)
6366
list_with_sep[::2] = list_of_columns
6467
return np.sum(list_with_sep, axis=0)

0 commit comments

Comments
 (0)