Skip to content

Commit

Permalink
Fix for issue pandas-dev#11317
Browse files Browse the repository at this point in the history
This includes updates to 3 Excel files, plus a test in test_excel.py,
plus the fix in parsers.py
  • Loading branch information
Dr-Irv committed Oct 14, 2015
1 parent 3914e0f commit 6a4c85d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ def _extract_multi_indexer_columns(self, header, index_names, col_names,
field_count = len(header[0])

def extract(r):
return tuple([r[i] for i in range(field_count) if i not in sic])
return tuple([str(r[i]) for i in range(field_count) if i not in sic])

columns = lzip(*[extract(r) for r in header])
names = ic + columns
Expand Down
Binary file modified pandas/io/tests/data/testmultiindex.xls
Binary file not shown.
Binary file modified pandas/io/tests/data/testmultiindex.xlsm
Binary file not shown.
Binary file modified pandas/io/tests/data/testmultiindex.xlsx
Binary file not shown.
6 changes: 6 additions & 0 deletions pandas/io/tests/test_excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,12 @@ def test_read_excel_multiindex(self):
actual = read_excel(mi_file, 'mi_column_name', header=[0,1], index_col=0)
tm.assert_frame_equal(actual, expected)

# Issue #11317
expected.columns = mi.set_levels(['1','2'],level=1).set_names(['c1', 'c2'])
actual = read_excel(mi_file, 'name_with_int', index_col=0, header=[0,1])
tm.assert_frame_equal(actual, expected)

expected.columns = mi.set_names(['c1', 'c2'])
expected.index = mi.set_names(['ilvl1', 'ilvl2'])
actual = read_excel(mi_file, 'both_name', index_col=[0,1], header=[0,1])
tm.assert_frame_equal(actual, expected)
Expand Down

0 comments on commit 6a4c85d

Please sign in to comment.