From 2e0d03a9a104d5ea0579225339002512b694834b Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Sun, 2 Dec 2018 13:05:13 +0100 Subject: [PATCH 1/3] PERF: Add if branch for empty sep in str.cat --- pandas/core/strings.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pandas/core/strings.py b/pandas/core/strings.py index 54882d039f135..984410d0e580e 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -59,6 +59,8 @@ def cat_core(list_of_columns: List, sep: str): nd.array The concatenation of list_of_columns with sep """ + if sep == '': + 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) From c1083f43501b2d5106be9b66c6b1a1592dc19d91 Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Tue, 30 Jul 2019 09:49:11 +0200 Subject: [PATCH 2/3] blackify --- pandas/core/strings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/strings.py b/pandas/core/strings.py index 984410d0e580e..7c77444749a25 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -59,7 +59,7 @@ def cat_core(list_of_columns: List, sep: str): nd.array The concatenation of list_of_columns with sep """ - if sep == '': + if sep == "": 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 From 637686b941f6020158892a748ab7b6c68da1ee1f Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Tue, 30 Jul 2019 09:53:43 +0200 Subject: [PATCH 3/3] add comment --- pandas/core/strings.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/core/strings.py b/pandas/core/strings.py index 7c77444749a25..43514153b0515 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -60,6 +60,7 @@ def cat_core(list_of_columns: List, sep: str): The concatenation of list_of_columns with sep """ if sep == "": + # no need to interleave sep if it is empty 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