Skip to content

Commit

Permalink
BUG: fix engine='python' integer outside fp rep range issue. close #3258
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed Apr 8, 2013
1 parent dc62479 commit 6b5ee26
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
3 changes: 3 additions & 0 deletions RELEASE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,8 @@ pandas 0.11.0
- Fixed a bug in the legend of plotting.andrews_curves() (GH3278_)
- Produce a series on apply if we only generate a singular series and have
a simple index (GH2893_)
- Fix Python ascii file parsing when integer falls outside of floating point
spacing (GH3258_)

.. _GH622: https://github.com/pydata/pandas/issues/622
.. _GH797: https://github.com/pydata/pandas/issues/797
Expand Down Expand Up @@ -381,6 +383,7 @@ pandas 0.11.0
.. _GH3222: https://github.com/pydata/pandas/issues/3222
.. _GH2641: https://github.com/pydata/pandas/issues/2641
.. _GH3238: https://github.com/pydata/pandas/issues/3238
.. _GH3258: https://github.com/pydata/pandas/issues/3258
.. _GH3283: https://github.com/pydata/pandas/issues/3283

pandas 0.10.1
Expand Down
27 changes: 27 additions & 0 deletions pandas/io/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1548,6 +1548,33 @@ def test_int64_min_issues(self):

tm.assert_frame_equal(result, expected)

def test_parse_integers_above_fp_precision(self):
data = """Numbers
17007000002000191
17007000002000191
17007000002000191
17007000002000191
17007000002000192
17007000002000192
17007000002000192
17007000002000192
17007000002000192
17007000002000194"""

result = self.read_csv(StringIO(data))
expected = DataFrame({'Numbers': [17007000002000191,
17007000002000191,
17007000002000191,
17007000002000191,
17007000002000192,
17007000002000192,
17007000002000192,
17007000002000192,
17007000002000192,
17007000002000194]})

self.assertTrue(np.array_equal(result['Numbers'], expected['Numbers']))


class TestPythonParser(ParserTests, unittest.TestCase):

Expand Down
7 changes: 5 additions & 2 deletions pandas/src/inference.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,10 @@ def maybe_convert_numeric(ndarray[object] values, set na_values,
elif 'inf' in val: # special case to handle +/-inf
seen_float = 1
elif fval < fINT64_MAX and fval > fINT64_MIN:
ints[i] = <int64_t> fval
try:
ints[i] = int(val)
except ValueError:
ints[i] = <int64_t> fval
else:
seen_float = 1
except:
Expand All @@ -402,7 +405,7 @@ def maybe_convert_numeric(ndarray[object] values, set na_values,

floats[i] = nan
seen_float = 1


if seen_complex:
return complexes
Expand Down

0 comments on commit 6b5ee26

Please sign in to comment.