Skip to content

Commit 3bee5d7

Browse files
committed
add more error messages for different numpy versions
1 parent f1f896b commit 3bee5d7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pandas/core/strings.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -2345,12 +2345,13 @@ def _legal_dtype(series):
23452345
# no NaNs - can just concatenate
23462346
result = cat_core(all_cols, sep)
23472347
except TypeError as exc:
2348-
m = re.match(r'can only concatenate str \(not \"(\w+)\"\) to str',
2349-
str(exc))
2350-
if m:
2351-
raise TypeError(err_wrong_dtype
2352-
+ ' Received list-like containing element of'
2353-
+ ' type: {}'.format(m.group(1)))
2348+
if re.match((r'can only concatenate str \(not [\w\"]+) to str'
2349+
r'|' # different numpy version have...
2350+
r'Can\'t convert [\w\']+ object to str implicitly'
2351+
r'|' # ... different error messages in np.sum
2352+
r'must be str, not \w+'),
2353+
str(exc)):
2354+
raise TypeError(err_wrong_dtype)
23542355
raise exc
23552356

23562357
if isinstance(self._orig, Index):

0 commit comments

Comments
 (0)