Skip to content

Commit aa117bc

Browse files
committed
Fix panel case
1 parent f7902e4 commit aa117bc

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

pandas/core/reshape/concat.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,11 +230,18 @@ def concat(objs, axis=0, join='outer', join_axes=None, ignore_index=False,
230230
warnings.warn('The join_axes-keyword is deprecated. Use .reindex or '
231231
'.reindex_like on the result to achieve the same '
232232
'functionality.', FutureWarning, stacklevel=2)
233-
if len(join_axes) > 1:
233+
ndim = res.ndim
234+
if len(join_axes) != ndim - 1:
234235
raise AssertionError("join_axes must be a list of indexes of "
235-
"length {length}".format(length=1))
236-
other_axis = 1 if axis == 0 else 0 # switches between 0 & 1
237-
res = res.reindex(join_axes[0], axis=other_axis)
236+
"length {length}".format(length=ndim - 1))
237+
if ndim == 2:
238+
other_axis = 1 if axis == 0 else 0 # switches between 0 & 1
239+
res = res.reindex(join_axes[0], axis=other_axis)
240+
else: # 3 for Panel; Panel4D already deprecated
241+
other_axes = list(range(res.ndim))
242+
other_axes.pop(axis)
243+
for i in range(ndim - 1):
244+
res.reindex(join_axes[i], axis=i)
238245
return res
239246

240247

0 commit comments

Comments
 (0)