Skip to content

AttributeError: module 'pandas.io.formats' has no attribute 'style' #24884

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

Closed
nuistzhou opened this issue Jan 23, 2019 · 3 comments
Closed

AttributeError: module 'pandas.io.formats' has no attribute 'style' #24884

nuistzhou opened this issue Jan 23, 2019 · 3 comments

Comments

@nuistzhou
Copy link

nuistzhou commented Jan 23, 2019

def clear(self):
""""Reset" the styler, removing any previously applied styles.
Returns None.
"""
self.ctx.clear()
self._todo = []

I am using the Pandas version 0.23.4.
When I call pandas.io.formats.style.Styler.clear(), it gives the error: "AttributeError: module 'pandas.io.formats' has no attribute 'style'".
However, I could find the 'style.py' under the Pandas installation folder.

@TomAugspurger
Copy link
Contributor

A few things.

  1. pandas.io.formats.style isn't imported with import pandas. You'd need import pandas.io.formats.style, but
  2. After that, Styler.clear() won't work because it's called on instances of the styler object. Something like Styler().clear() would work. But,
  3. You probably don't want that either. Typically you create these frame a DataFrame.
In [8]: df = pd.DataFrame({"A": [1, 2]})

In [9]: df.style
Out[9]: <pandas.io.formats.style.Styler at 0x10b9b6ba8>

In [10]: df.style.clear()

@nuistzhou
Copy link
Author

Oh, cool.
BTW, I forgot to mention that what I need is to unbold the headers when using the to_excel() method. However, the code df.style.clear() seems does not work.

@WillAyd
Copy link
Member

WillAyd commented Jan 24, 2019

@nuistzhou you should take a look at #22773 and #22759 which may yield insights on what you are trying to do. Specifically with the former we could use some help on documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants