-
-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Open
Labels
DocsNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further actionOutput-Formatting__repr__ of pandas objects, to_string__repr__ of pandas objects, to_string
Description
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
Metadata
Metadata
Assignees
Labels
DocsNeeds DiscussionRequires discussion from core team before further actionRequires discussion from core team before further actionOutput-Formatting__repr__ of pandas objects, to_string__repr__ of pandas objects, to_string
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
geoffrey-eisenbarth commentedon Apr 3, 2019
Has there been any progress on this? I ended up just changing the new
header_style
property to returnNone
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 commentedon Apr 3, 2019
geoffrey-eisenbarth commentedon Apr 4, 2019
I would love to contribute, I'll look more into the relevant code tonight and tomorrow.
johncthomas commentedon 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 toDataFrame.to_excel
with default value ofpandas.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.
DataFrame.to_excel
to output unformatted excel file #54154