diff --git a/pandas/core/panel.py b/pandas/core/panel.py index e4515efe109c58..906866a3580298 100644 --- a/pandas/core/panel.py +++ b/pandas/core/panel.py @@ -26,7 +26,7 @@ from pandas.core.frame import DataFrame from pandas.core.generic import NDFrame, _shared_docs from pandas.core.index import (Index, MultiIndex, _ensure_index, - _get_combined_index) + _get_objs_combined_axis) from pandas.io.formats.printing import pprint_thing from pandas.core.indexing import maybe_droplevels from pandas.core.internals import (BlockManager, @@ -1448,7 +1448,6 @@ def _extract_axis(self, data, axis=0, intersect=False): index = Index([]) elif len(data) > 0: raw_lengths = [] - indexes = [] have_raw_arrays = False have_frames = False @@ -1456,13 +1455,14 @@ def _extract_axis(self, data, axis=0, intersect=False): for v in data.values(): if isinstance(v, self._constructor_sliced): have_frames = True - indexes.append(v._get_axis(axis)) elif v is not None: have_raw_arrays = True raw_lengths.append(v.shape[axis]) if have_frames: - index = _get_combined_index(indexes, intersect=intersect) + index = _get_objs_combined_axis(data.values(), axis=axis, + intersect=intersect) + if have_raw_arrays: lengths = list(set(raw_lengths)) diff --git a/pandas/core/reshape/concat.py b/pandas/core/reshape/concat.py index e199ec27103674..5f79fc5f6991d9 100644 --- a/pandas/core/reshape/concat.py +++ b/pandas/core/reshape/concat.py @@ -4,7 +4,7 @@ import numpy as np from pandas import compat, DataFrame, Series, Index, MultiIndex -from pandas.core.index import (_get_combined_index, +from pandas.core.index import (_get_objs_combined_axis, _ensure_index, _get_consensus_names, _all_indexes_same) from pandas.core.categorical import (_factorize_from_iterable, @@ -445,16 +445,13 @@ def _get_new_axes(self): return new_axes def _get_comb_axis(self, i): - if self._is_series: - all_indexes = [x.index for x in self.objs] - else: - try: - all_indexes = [x._data.axes[i] for x in self.objs] - except IndexError: - types = [type(x).__name__ for x in self.objs] - raise TypeError("Cannot concatenate list of %s" % types) - - return _get_combined_index(all_indexes, intersect=self.intersect) + data_axis = 1 - i if self.objs[0].ndim == 2 else i + try: + return _get_objs_combined_axis(self.objs, axis=data_axis, + intersect=self.intersect) + except IndexError: + types = [type(x).__name__ for x in self.objs] + raise TypeError("Cannot concatenate list of %s" % types) def _get_concat_axis(self): """