Skip to content

engine xlsxwriter fails for np.inf #6782

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
arthurgerigk-rocket opened this issue Apr 3, 2014 · 8 comments · Fixed by #6812
Closed

engine xlsxwriter fails for np.inf #6782

arthurgerigk-rocket opened this issue Apr 3, 2014 · 8 comments · Fixed by #6812
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions IO Excel read_excel, to_excel
Milestone

Comments

@arthurgerigk-rocket
Copy link

this works for openpyxl but it fails for xlsxwriter

TypeError("NAN/INF not supported in write_number()")

@jreback
Copy link
Contributor

jreback commented Apr 3, 2014

do nans raise the same? or just inf?

@jreback jreback added this to the 0.15.0 milestone Apr 3, 2014
@jreback
Copy link
Contributor

jreback commented Apr 3, 2014

cc @jmcnamara

@arthurgerigk-rocket
Copy link
Author

nans are fine

On Thu, Apr 3, 2014 at 7:19 PM, jreback [email protected] wrote:

cc @jmcnamara https://github.com/jmcnamara

Reply to this email directly or view it on GitHubhttps://github.com//issues/6782#issuecomment-39478741
.

Arthur Gerigk
Global CMO

Rocket Internet GmbH | Johannisstraße 20 | 10117 Berlin | Deutschland
Mobile: +49 162 290 46 39 | skype: arthur.gerigk | mail:
[email protected]
www.rocket-internet.de

Geschäftsführer: Dr. Johannes Bruder, Arnt Jeschke, Alexander Kudlich
Eingetragen beim Amtsgericht Berlin, HRB 109262 USt-ID DE256469659

@jmcnamara
Copy link
Contributor

I don't think NAN/INF are supported by Excel so I am curious to see what OpenPyXL is doing in this case.

Can you post a small example that demonstrates the issue and I'll look into it.

@arthurgerigk-rocket
Copy link
Author

to_excel has a parameter "na_rep" which defaults to the empty string.
actually there are NA values in excel
http://office.microsoft.com/en-001/excel-help/na-HP005209188.aspx

On Thu, Apr 3, 2014 at 7:39 PM, John McNamara [email protected]:

I don't think NAN/INF are supported by Excel so I am curious to see what
OpenPyXL is doing in this case.

Can you post a small example that demonstrates the issue and I'll look
into it.

Reply to this email directly or view it on GitHubhttps://github.com//issues/6782#issuecomment-39481271
.

Arthur Gerigk
Global CMO

Rocket Internet GmbH | Johannisstraße 20 | 10117 Berlin | Deutschland
Mobile: +49 162 290 46 39 | skype: arthur.gerigk | mail:
[email protected]
www.rocket-internet.de

Geschäftsführer: Dr. Johannes Bruder, Arnt Jeschke, Alexander Kudlich
Eingetragen beim Amtsgericht Berlin, HRB 109262 USt-ID DE256469659

@jmcnamara
Copy link
Contributor

NA is only supported in Excel as a formula or as the result of a formula. Not as a value.

If you post an example I'll have a look at it.

@arthurgerigk-rocket
Copy link
Author

import numpy as np
import pandas as pd
df = pd.DataFrame([(1, np.nan), (2, 3)])
df.to_excel('test.xlsx') # works

df = pd.DataFrame([(1, np.inf), (2, 3)])
df.to_excel('test2.xlsx') # fails

since there is a parameter np_rep I think it has to work ;-)

On Thu, Apr 3, 2014 at 8:14 PM, John McNamara [email protected]:

NA is only supported in Excel as a formula or as the result of a formula.
Not as a value.

If you post an example I'll have a look at it.

Reply to this email directly or view it on GitHubhttps://github.com//issues/6782#issuecomment-39485412
.

Arthur Gerigk
Global CMO

Rocket Internet GmbH | Johannisstraße 20 | 10117 Berlin | Deutschland
Mobile: +49 162 290 46 39 | skype: arthur.gerigk | mail:
[email protected]
www.rocket-internet.de

Geschäftsführer: Dr. Johannes Bruder, Arnt Jeschke, Alexander Kudlich
Eingetragen beim Amtsgericht Berlin, HRB 109262 USt-ID DE256469659

@jtratner
Copy link
Contributor

jtratner commented Apr 5, 2014

Let's follow the model of to_csv/read_csv and output np.inf as the string 'inf', which will be able to be round-tripped appropriately.

Side note - I can't open up the openpyxl file after it's written - so I'm not sure if openpyxl is doing the right thing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Dtype Conversions Unexpected or buggy dtype conversions IO Excel read_excel, to_excel
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants