@@ -3289,6 +3289,12 @@ def create_axes(self, axes, obj, validate=True, nan_rep=None,
3289
3289
def process_axes (self , obj , columns = None ):
3290
3290
""" process axes filters """
3291
3291
3292
+ # make sure to include levels if we have them
3293
+ if columns is not None and self .is_multi_index :
3294
+ for n in self .levels :
3295
+ if n not in columns :
3296
+ columns .insert (0 , n )
3297
+
3292
3298
# reorder by any non_index_axes & limit to the select columns
3293
3299
for axis , labels in self .non_index_axes :
3294
3300
obj = _reindex_axis (obj , axis , labels , columns )
@@ -3305,6 +3311,12 @@ def process_filter(field, filt):
3305
3311
3306
3312
# see if the field is the name of an axis
3307
3313
if field == axis_name :
3314
+
3315
+ # if we have a multi-index, then need to include
3316
+ # the levels
3317
+ if self .is_multi_index :
3318
+ filt = filt + Index (self .levels )
3319
+
3308
3320
takers = op (axis_values , filt )
3309
3321
return obj .ix ._getitem_axis (takers ,
3310
3322
axis = axis_number )
@@ -3951,31 +3963,18 @@ def write(self, obj, data_columns=None, **kwargs):
3951
3963
return super (AppendableMultiFrameTable , self ).write (
3952
3964
obj = obj , data_columns = data_columns , ** kwargs )
3953
3965
3954
- def read (self , columns = None , ** kwargs ):
3955
- if columns is not None :
3956
- for n in self .levels :
3957
- if n not in columns :
3958
- columns .insert (0 , n )
3959
- df = super (AppendableMultiFrameTable , self ).read (
3960
- columns = columns , ** kwargs )
3961
- try :
3962
- df = df .set_index (self .levels )
3963
- except KeyError :
3964
- if kwargs .get ('where' ) is not None and 'columns' in kwargs .get ('where' ).expr :
3965
- raise KeyError (
3966
- "Indexes columns were not retrieved because you passed "
3967
- "a `where` argument containing columns specification. "
3968
- "(see http://github.com/pydata/pandas/issues/6169), try passing "
3969
- "the columns specification through the `columns` keyword instead"
3970
- )
3966
+ def read (self , ** kwargs ):
3967
+
3968
+ df = super (AppendableMultiFrameTable , self ).read (** kwargs )
3969
+ df = df .set_index (self .levels )
3970
+
3971
3971
# remove names for 'level_%d'
3972
3972
df .index = df .index .set_names ([
3973
3973
None if self ._re_levels .search (l ) else l for l in df .index .names
3974
3974
])
3975
3975
3976
3976
return df
3977
3977
3978
-
3979
3978
class AppendablePanelTable (AppendableTable ):
3980
3979
3981
3980
""" suppor the new appendable table formats """
0 commit comments