1

After exporting MultiIndex DataFrame to an Excel file, an additional row between the header and the rows is created. How can I avoid that? enter image description here

writer = pd.ExcelWriter(out_xlsx, engine='xlsxwriter')
df1.to_excel(writer, sheet_name='All Instances', merge_cells=True)

Did anyone experience similar behaviour?

1 Answer 1

1

That is a known issue/feature in Pandas. See this GitHub Issue for an explanation.

This Stack Overflow answer is probably the best workaround I’ve seen.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.