Skip to content

BUG: Excel writer doesn't handle "cols" option correctly #5427

Closed
@jmcnamara

Description

@jmcnamara

This is an issue that I introduced when fixing #5235.

The cols option in to_excel no longer works correctly after the fix for the above issue. For example:

import pandas as pd

df = pd.DataFrame({'A': ['a', 'a', 'a'],
                   'B': ['b', 'b', 'b']})

df.to_excel('frame.xlsx', sheet_name='Sheet1', cols=['B', 'A'])

Gives:

screenshot

Note, the headers are changed but not the column data.

I have a proposed fix and test for this. Should I create a new branch/PR or merge it into the Excel MultiIndex PR: #5423

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions