@@ -2910,9 +2910,7 @@ def create_axes(self, axes, obj, validate=True, nan_rep=None, data_columns=None,
2910
2910
2911
2911
# reindex by our non_index_axes & compute data_columns
2912
2912
for a in self .non_index_axes :
2913
- labels = _ensure_index (a [1 ])
2914
- if not labels .equals (obj ._get_axis (a [0 ])):
2915
- obj = obj .reindex_axis (labels , axis = a [0 ])
2913
+ obj = _reindex_axis (obj , a [0 ], a [1 ])
2916
2914
2917
2915
# figure out data_columns and get out blocks
2918
2916
block_obj = self .get_object (obj ).consolidate ()
@@ -3000,11 +2998,7 @@ def process_axes(self, obj, columns=None):
3000
2998
3001
2999
# reorder by any non_index_axes & limit to the select columns
3002
3000
for axis , labels in self .non_index_axes :
3003
- if columns is not None :
3004
- labels = Index (labels ) & Index (columns )
3005
- labels = _ensure_index (labels )
3006
- if not labels .equals (obj ._get_axis (axis )):
3007
- obj = obj .reindex_axis (labels , axis = axis )
3001
+ obj = _reindex_axis (obj , axis , labels , columns )
3008
3002
3009
3003
# apply the selection filters (but keep in the same order)
3010
3004
if self .selection .filter :
@@ -3683,6 +3677,21 @@ class AppendableNDimTable(AppendablePanelTable):
3683
3677
obj_type = Panel4D
3684
3678
3685
3679
3680
+ def _reindex_axis (obj , axis , labels , other = None ):
3681
+ ax = obj ._get_axis (axis )
3682
+ labels = _ensure_index (labels )
3683
+ if other is None and labels .equals (ax ):
3684
+ return obj
3685
+
3686
+ labels = _ensure_index (labels .unique ())
3687
+ if other is not None :
3688
+ labels = labels & _ensure_index (other )
3689
+ if not labels .equals (ax ):
3690
+ slicer = [ slice (None , None ) ] * obj .ndim
3691
+ slicer [axis ] = labels
3692
+ obj = obj .loc [tuple (slicer )]
3693
+ return obj
3694
+
3686
3695
def _get_info (info , name ):
3687
3696
""" get/create the info for this name """
3688
3697
try :
0 commit comments