Skip to content

Expose Formatters via API and Improve Documentation #22773

@WillAyd

Description

@WillAyd
Member

See the discussion in #22759 (comment) - we could potentially expose the formatters via the public API and allow users to subclass them or even assign properties to them which give finer control over what gets exported.

I've had an actual use case for this for at least the ExcelFormatter to change the exported header formatting. Haven't had as much of a use case for other Formatters but would love input

Activity

added
Output-Formatting__repr__ of pandas objects, to_string
Needs DiscussionRequires discussion from core team before further action
on Sep 19, 2018
geoffrey-eisenbarth

geoffrey-eisenbarth commented on Apr 3, 2019

@geoffrey-eisenbarth
Contributor

Has there been any progress on this? I ended up just changing the new header_style property to return None in the source so I can to have full control of formatting with XlsxWriter. Not ideal, but gives me what I need for now.

Is there a more appropriate way to do this?

WillAyd

WillAyd commented on Apr 3, 2019

@WillAyd
MemberAuthor
geoffrey-eisenbarth

geoffrey-eisenbarth commented on Apr 4, 2019

@geoffrey-eisenbarth
Contributor

I would love to contribute, I'll look more into the relevant code tonight and tomorrow.

johncthomas

johncthomas commented on Jul 4, 2020

@johncthomas

So I spent half a day trying to write a workaround to this that failed in certain cases so I should probably fix it in the source code. I've never contributed to an open source project so here's what I'm thinking in case I'm planning something dumb:

  • Add header_format & index_format args to DataFrame.to_excel with default value of pandas.io.formats.excel.ExcelFormatter.header_style

  • Change ExcelFormatter to implement any passed style dict, or None with no formatting applied

edit: Oh, I'm only talking about the header/index formatters, looks like the scope of this issue is wider and I don't really know what people are looking for there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocsNeeds DiscussionRequires discussion from core team before further actionOutput-Formatting__repr__ of pandas objects, to_string

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @WillAyd@geoffrey-eisenbarth@johncthomas

        Issue actions

          Expose Formatters via API and Improve Documentation · Issue #22773 · pandas-dev/pandas