Skip to content

to_excel() float_format to accept this format string? #8191

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
finoptimal-dev opened this issue Sep 5, 2014 · 3 comments
Closed

to_excel() float_format to accept this format string? #8191

finoptimal-dev opened this issue Sep 5, 2014 · 3 comments
Labels
IO Excel read_excel, to_excel

Comments

@finoptimal-dev
Copy link

I want to have thousands separators in Excel, but when I pass float_format="%,.2f" in I get an unsupported character error. I also tried "{0:,}". Am I missing something or is this unsupported?

@TomAugspurger
Copy link
Contributor

As far as I know the new style formatters aren't accepted as float formatters (see #4668). Is there a way to specify the thousands separator with old style string formatting? "%,.2f" has Python raising a ValueError, not pandas.

Also Excel may have additional issues. IIRC they store everything as floats and apply formatting to them in excel, but I could be wrong.

@jtratner
Copy link
Contributor

jtratner commented Sep 7, 2014

This is a Python issue, not an Excel issue:

In [1]: '%,.2f' % 1000
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-1-fa27f61d10d9> in <module>()
----> 1 '%,.2f' % 1000

ValueError: unsupported format character ',' (0x2c) at index 1

So it's not really possible to do this for any output format. (but you can convert it yourself beforehand)

@jtratner jtratner added the IO Excel read_excel, to_excel label Sep 19, 2014
@jreback
Copy link
Contributor

jreback commented Oct 20, 2015

closing as stale. pls reopen if still an issue.

@jreback jreback closed this as completed Oct 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
IO Excel read_excel, to_excel
Projects
None yet
Development

No branches or pull requests

4 participants