From fad997fa53ea1cf5a147ac0bd0f1729813733cca Mon Sep 17 00:00:00 2001 From: "H. Vetinari" Date: Wed, 10 Oct 2018 22:38:16 +0200 Subject: [PATCH] Add np-compat --- pandas/core/strings.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pandas/core/strings.py b/pandas/core/strings.py index e63dc2b6e7e42d..ebdd2905e29e1b 100644 --- a/pandas/core/strings.py +++ b/pandas/core/strings.py @@ -18,6 +18,7 @@ import pandas.core.common as com from pandas.core.algorithms import take_1d import pandas.compat as compat +from pandas.compat.numpy import _np_version_under1p11 from pandas.core.base import NoNewAttributesMixin from pandas.util._decorators import Appender import re @@ -57,9 +58,12 @@ def cat_core(all_cols, sep): list_of_columns = np.split(all_cols, all_cols.shape[1], axis=1) list_with_sep = [sep] * (2 * len(list_of_columns) - 1) list_with_sep[::2] = list_of_columns - # np.split splits into arrays of shape (N, 1); NOT (N,) - # need to reduce dimensionality of result - return np.sum(list_with_sep, axis=0)[:, 0] + res = np.sum(list_with_sep, axis=0) + if not (_np_version_under1p11 and len(res) == 0): + # np.split splits into arrays of shape (N, 1); NOT (N,) + # need to reduce dimensionality of result + res = res[:, 0] + return res def _na_map(f, arr, na_result=np.nan, dtype=object):