@@ -615,7 +615,7 @@ def test_roundtrip_indexlabels(self):
615
615
has_index_names = self .merge_cells
616
616
).astype (np .int64 )
617
617
frame .index .names = ['test' ]
618
- tm .assert_frame_equal (frame ,recons .astype (bool ))
618
+ tm .assert_frame_equal (frame , recons .astype (bool ))
619
619
620
620
with ensure_clean (self .ext ) as path :
621
621
@@ -715,6 +715,31 @@ def test_to_excel_multiindex_dates(self):
715
715
tm .assert_frame_equal (tsframe , recons )
716
716
self .assertEquals (recons .index .names , ('time' , 'foo' ))
717
717
718
+ def test_to_excel_multiindex_no_write_index (self ):
719
+ _skip_if_no_xlrd ()
720
+
721
+ # Test writing and re-reading a MI witout the index. GH 5616.
722
+
723
+ # Initial non-MI frame.
724
+ frame1 = pd .DataFrame ({'a' : [10 , 20 ], 'b' : [30 , 40 ], 'c' : [50 , 60 ]})
725
+
726
+ # Add a MI.
727
+ frame2 = frame1 .copy ()
728
+ multi_index = pd .MultiIndex .from_tuples ([(70 , 80 ), (90 , 100 )])
729
+ frame2 .index = multi_index
730
+
731
+ with ensure_clean (self .ext ) as path :
732
+
733
+ # Write out to Excel without the index.
734
+ frame2 .to_excel (path , 'test1' , index = False )
735
+
736
+ # Read it back in.
737
+ reader = ExcelFile (path )
738
+ frame3 = reader .parse ('test1' )
739
+
740
+ # Test that it is the same as the initial frame.
741
+ tm .assert_frame_equal (frame1 , frame3 )
742
+
718
743
def test_to_excel_float_format (self ):
719
744
_skip_if_no_xlrd ()
720
745
0 commit comments