Skip to content

Commit 05c4c2d

Browse files
AdamShamlianalanbato
authored andcommitted
CLN/TST: amended TypeError from pd.concat() to be more informative (pandas-dev#15796) (pandas-dev#17885)
1 parent b53abbe commit 05c4c2d

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

pandas/core/reshape/concat.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,10 @@ def __init__(self, objs, axis=0, join='outer', join_axes=None,
262262
ndims = set()
263263
for obj in objs:
264264
if not isinstance(obj, NDFrame):
265-
raise TypeError("cannot concatenate a non-NDFrame object")
265+
msg = ('cannot concatenate object of type "{0}";'
266+
' only pd.Series, pd.DataFrame, and pd.Panel'
267+
' (deprecated) objs are valid'.format(type(obj)))
268+
raise TypeError(msg)
266269

267270
# consolidate
268271
obj._consolidate(inplace=True)

pandas/tests/reshape/test_concat.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ def test_concatlike_same_dtypes(self):
177177
tm.assert_series_equal(res, exp, check_index_type=True)
178178

179179
# cannot append non-index
180-
msg = "cannot concatenate a non-NDFrame object"
180+
msg = ('cannot concatenate object of type \"(.+?)\";'
181+
' only pd.Series, pd.DataFrame, and pd.Panel'
182+
' \(deprecated\) objs are valid')
181183
with tm.assert_raises_regex(TypeError, msg):
182184
pd.Series(vals1).append(vals2)
183185

0 commit comments

Comments
 (0)