Skip to content

Commit a97fe67

Browse files
committed
Add np-compat
1 parent 36c6240 commit a97fe67

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pandas/core/strings.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import pandas.core.common as com
1919
from pandas.core.algorithms import take_1d
2020
import pandas.compat as compat
21+
from pandas.compat.numpy import _np_version_under1p11
2122
from pandas.core.base import NoNewAttributesMixin
2223
from pandas.util._decorators import Appender
2324
import re
@@ -57,9 +58,12 @@ def cat_core(all_cols, sep):
5758
list_of_columns = np.split(all_cols, all_cols.shape[1], axis=1)
5859
list_with_sep = [sep] * (2 * len(list_of_columns) - 1)
5960
list_with_sep[::2] = list_of_columns
60-
# np.split splits into arrays of shape (N, 1); NOT (N,)
61-
# need to reduce dimensionality of result
62-
return np.sum(list_with_sep, axis=0)[:, 0]
61+
res = np.sum(list_with_sep, axis=0)
62+
if not (_np_version_under1p11 and len(res) == 0):
63+
# np.split splits into arrays of shape (N, 1); NOT (N,)
64+
# need to reduce dimensionality of result
65+
res = res[:, 0]
66+
return res
6367

6468

6569
def _na_map(f, arr, na_result=np.nan, dtype=object):

0 commit comments

Comments
 (0)