Skip to content

engine xlsxwriter fails for np.inf #6782

@arthurgerigk-rocket

Description

@arthurgerigk-rocket

this works for openpyxl but it fails for xlsxwriter

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

Activity

jreback

jreback commented on Apr 3, 2014

@jreback
Contributor

do nans raise the same? or just inf?

added this to the 0.15.0 milestone on Apr 3, 2014
jreback

jreback commented on Apr 3, 2014

@jreback
Contributor
arthurgerigk-rocket

arthurgerigk-rocket commented on Apr 3, 2014

@arthurgerigk-rocket
Author

nans are fine

On Thu, Apr 3, 2014 at 7:19 PM, jreback notifications@github.com 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:
arthur.gerigk@rocket-internet.de
www.rocket-internet.de

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

jmcnamara

jmcnamara commented on Apr 3, 2014

@jmcnamara
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

arthurgerigk-rocket commented on Apr 3, 2014

@arthurgerigk-rocket
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 notifications@github.comwrote:

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:
arthur.gerigk@rocket-internet.de
www.rocket-internet.de

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

jmcnamara

jmcnamara commented on Apr 3, 2014

@jmcnamara
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

arthurgerigk-rocket commented on Apr 3, 2014

@arthurgerigk-rocket
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 notifications@github.comwrote:

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:
arthur.gerigk@rocket-internet.de
www.rocket-internet.de

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

jtratner

jtratner commented on Apr 5, 2014

@jtratner
Contributor

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.

self-assigned this
on Apr 5, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsIO Excelread_excel, to_excel

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      Participants

      @jmcnamara@jreback@jtratner@arthurgerigk-rocket

      Issue actions

        engine xlsxwriter fails for np.inf · Issue #6782 · pandas-dev/pandas