-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
BUG/ENH: Fix to_excel representation of inf values #6812
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
Conversation
should also handle -inf |
@jreback good call - any preference between |
I think u should use isinfinite maybe has better platform compat (or may be the same) |
Yeah, realized that after I said it haha |
okay, that's done. |
ok looks fine side note - this formatting to excel space should be done by blocks - would make it much faster (but separate issue) |
that's a good point. - let's accept this for now (along with the extra tests to spec out inf) and then we can go back to that later on. |
BUG/ENH: Fix to_excel representation of inf values
if self.float_format is not None and com.is_float(val): | ||
val = float(self.float_format % val) | ||
elif com.is_float(val): | ||
if np.isposinf(val): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like -inf is being written for positive infinite values and vice versa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that seems wrong
Fixes #6782 by converting inf values to string (default is
'inf'
).This still round trips successfully. According to Stack Overflow post I
found, there isn't a specific representation of
INF
values -http://stackoverflow.com/questions/15704538/how-can-i-express-nan-values-in-excel
so we're going to make the decision for the writers. This also
(implicitly) fixes an issues where round-tripping an Excel file with an
inf value would cause an
OverflowError
and fail to read back.cc @jmcnamara and @arthurgerigk-rocket