Skip to content
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

excel header_style broken in 0.22 #19386

Closed
gordol opened this issue Jan 25, 2018 · 9 comments
Closed

excel header_style broken in 0.22 #19386

gordol opened this issue Jan 25, 2018 · 9 comments
Labels
API Design IO Excel read_excel, to_excel

Comments

@gordol
Copy link

gordol commented Jan 25, 2018

import pandas as pd
pd.io.formats.excel.header_style = None

After updating, it is no longer possible to override the excel header styles.

Previously, this was possible in 0.19.2:

pd.formats.format.header_style = None

It seems header_style has been moving around constantly lately... Can we please put it somewhere and leave it there??? Or, if it's going to be moved constantly, it should live on a private module path. I realize python doesn't have private scoping, but there are paths in the pandas module that are privately scoped, by convention, yet don't follow the standard python convention of underscoring the names.

How are we supposed to accomplish the removal of styles on the latest build?

That module path DOES indeed exist... but something is wonky with the imports, it seems.

Exception is raised:
AttributeError: 'module' object has no attribute 'excel'

Possibly related? #15530

@gordol gordol changed the title excel header_styles broken in 0.22 excel header_style broken in 0.22 Jan 25, 2018
@chris-b1
Copy link
Contributor

For me this does work on 0.22 to remove the header styling

pd.io.formats.excel.header_style = None

But in any case, this wasn't intended to public - I do think it would be reasonable enhancement to add an argument to DataFrame.to_excel to handle this case if you're interested in doing a PR?

@chris-b1 chris-b1 added API Design IO Excel read_excel, to_excel labels Jan 25, 2018
@gordol
Copy link
Author

gordol commented Jan 25, 2018

Hmm...

I wonder why it's not working for me... Like I said, I can clearly see the module in my local path, and can see that line in the module... but it refuses to load.

Would that be added here?

def to_excel(self, excel_writer, sheet_name='Sheet1', na_rep='',

I'm not sure... looks like there's some kind of new styling module, and I'm totally lost as to where to even start... It probably supports what I need, but there's not much documentation on this (it's listed as experimental in the docs)

def to_excel(self, excel_writer, sheet_name='Sheet1', na_rep='',

@gordol
Copy link
Author

gordol commented Jan 25, 2018

Honestly, that looks like totally redundant code...

@gordol
Copy link
Author

gordol commented Jan 25, 2018

I'm okay with removing all styles... even. It doesn't even have to be just the headers.

@chris-b1
Copy link
Contributor

Ah I was forgetting about the styler enhancements, if you really want no styles, easy enough solution is df.style.to_excel('output.xlsx')

@WillAyd
Copy link
Member

WillAyd commented Jan 21, 2019

You should be able to override this now via #22759

@WillAyd WillAyd closed this as completed Jan 21, 2019
@yyz20002008
Copy link

@WillAyd
Hello
Currently header has a border and bolded. I don't want header has any format after it is converted to excel, then I used
df.io.formats.excel.header_style = None
Error was poped out:
AttributeError: 'DataFrame' object has no attribute 'io'
Then I saw
df.io.formats.excel.header_style = None doesn't work anymore since 0.24 from https://stackoverflow.com/questions/36694313/pandas-xlsxwriter-format-header

I saw your response, but I still didn't see any solution in #22759

Do you have any idea how to remove header format?

@WillAyd
Copy link
Member

WillAyd commented Jun 10, 2019

There isn't a currently exposed way of doing this. #25185 is open if you'd like to take a look and contribute something on that front

@Diegostastico
Copy link

Diegostastico commented May 31, 2021

From version 0.24 (Jan 25, 2019) this is now required:

import pandas.io.formats.excel
pandas.io.formats.excel.ExcelFormatter.header_style = None

currently still working for pandas version 1.2.4 (Apr 12, 2021)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Design IO Excel read_excel, to_excel
Projects
None yet
Development

No branches or pull requests

5 participants