Skip to content

API: to_excel with merge_cells=False treats index and columns differently #60274

Closed
@rhshadrach

Description

@rhshadrach
df = pd.DataFrame({"a": [1, 1], "b": [2, 3], "c": 4, "d": 5}).set_index(["a", "b"])
df.columns = pd.MultiIndex.from_tuples([("x", "y"), ("x", "z")])
df.to_excel("test.xlsx", merge_cells=False)

image

In the above the multi-level nature of the index is maintained, however the columns are collapsed to a single row in the form x.y, x.z. It seems to me that these should be treated the same. The output should be multiple rows of non-merged cells.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions