Skip to content

Expose Formatters via API and Improve Documentation #22773

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
WillAyd opened this issue Sep 19, 2018 · 4 comments
Open

Expose Formatters via API and Improve Documentation #22773

WillAyd opened this issue Sep 19, 2018 · 4 comments
Labels
Docs Needs Discussion Requires discussion from core team before further action Output-Formatting __repr__ of pandas objects, to_string

Comments

@WillAyd
Copy link
Member

WillAyd commented Sep 19, 2018

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

@geoffrey-eisenbarth
Copy link
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
Copy link
Member Author

WillAyd commented Apr 3, 2019 via email

@geoffrey-eisenbarth
Copy link
Contributor

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

@johncthomas
Copy link

johncthomas commented Jul 4, 2020

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
Labels
Docs Needs Discussion Requires discussion from core team before further action Output-Formatting __repr__ of pandas objects, to_string
Projects
None yet
Development

No branches or pull requests

3 participants