Skip to content

BUG: Fix for to_excel +/- infinity #7949

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

Merged
merged 1 commit into from
Sep 4, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/source/v0.15.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -621,11 +621,11 @@ Bug Fixes
return a non scalar value that appeared valid but wasn't (:issue:`7870`).
- Bug in ``date_range()``/``DatetimeIndex()`` when the timezone was inferred from input dates yet incorrect
times were returned when crossing DST boundaries (:issue:`7835`, :issue:`7901`).


- Bug in ``to_excel()`` where a negative sign was being prepended to positive infinity and was absent for negative infinity (:issue`7949`)
- Bug in area plot draws legend with incorrect ``alpha`` when ``stacked=True`` (:issue:`8027`)

- ``Period`` and ``PeriodIndex`` addition/subtraction with ``np.timedelta64`` results in incorrect internal representations (:issue:`7740`)
times were returned when crossing DST boundaries (:issue:`7835`, :issue:`7901`).
- Bug in ``to_excel()`` where a negative sign was being prepended to positive infinity and was absent for negative infinity (:issue`7949`)

- ``Holiday`` bug in Holiday with no offset or observance (:issue:`7987`)

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -1512,9 +1512,9 @@ def _format_value(self, val):
val = self.na_rep
elif com.is_float(val):
if np.isposinf(val):
val = '-%s' % self.inf_rep
elif np.isneginf(val):
val = self.inf_rep
elif np.isneginf(val):
val = '-%s' % self.inf_rep
elif self.float_format is not None:
val = float(self.float_format % val)
return val
Expand Down
4 changes: 4 additions & 0 deletions pandas/src/testing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ cpdef assert_almost_equal(a, b, bint check_less_precise=False):

if np.isinf(a):
assert np.isinf(b), "First object is inf, second isn't"
if np.isposinf(a):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you add this?

assert np.isposinf(b), "First object is positive inf, second is negative inf"
else:
assert np.isneginf(b), "First object is negative inf, second is positive inf"
else:
fa, fb = a, b

Expand Down