File tree 2 files changed +23
-0
lines changed
2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -3453,6 +3453,10 @@ def get_blk_items(mgr, blocks):
3453
3453
def process_axes (self , obj , columns = None ):
3454
3454
""" process axes filters """
3455
3455
3456
+ # make a copy to avoid side effects
3457
+ if columns is not None :
3458
+ columns = list (columns )
3459
+
3456
3460
# make sure to include levels if we have them
3457
3461
if columns is not None and self .is_multi_index :
3458
3462
for n in self .levels :
Original file line number Diff line number Diff line change @@ -4617,6 +4617,25 @@ def test_preserve_timedeltaindex_type(self):
4617
4617
store ['df' ] = df
4618
4618
assert_frame_equal (store ['df' ], df )
4619
4619
4620
+ def test_colums_multiindex_modified (self ):
4621
+ df = DataFrame (np .random .rand (4 , 5 ),
4622
+ index = list ('abcd' ),
4623
+ columns = list ('ABCDE' ))
4624
+ df .index .name = 'letters'
4625
+ df = df .set_index (keys = 'E' , append = True )
4626
+
4627
+ data_columns = df .index .names + df .columns .tolist ()
4628
+ with ensure_clean_path (self .path ) as path :
4629
+ df .to_hdf (path , 'df' ,
4630
+ mode = 'a' ,
4631
+ append = True ,
4632
+ data_columns = data_columns ,
4633
+ index = False )
4634
+ cols2load = list ('BCD' )
4635
+ cols2load_original = list (cols2load )
4636
+ df_loaded = read_hdf (path , 'df' , columns = cols2load )
4637
+ self .assertTrue (cols2load_original == cols2load )
4638
+
4620
4639
4621
4640
def _test_sort (obj ):
4622
4641
if isinstance (obj , DataFrame ):
You can’t perform that action at this time.
0 commit comments