Skip to content

Commit d957ad7

Browse files
committed
Merge pull request #4602 from cancan101/number_parsing
Fixes issue with TextFileReader using python engine and thousands != ","
2 parents b889fda + 0c0f962 commit d957ad7

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

doc/source/release.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,9 @@ Bug Fixes
429429
``ascending`` was being interpreted as ``True`` (:issue:`4839`,
430430
:issue:`4846`)
431431
- Fixed ``Panel.tshift`` not working. Added `freq` support to ``Panel.shift`` (:issue:`4853`)
432-
432+
- Fix an issue in TextFileReader w/ Python engine (i.e. PythonParser)
433+
with thousands != "," (:issue:`4596`)
434+
433435
pandas 0.12.0
434436
-------------
435437

pandas/io/parsers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1538,7 +1538,7 @@ def _check_thousands(self, lines):
15381538
nonnum.search(x.strip())):
15391539
rl.append(x)
15401540
else:
1541-
rl.append(x.replace(',', ''))
1541+
rl.append(x.replace(self.thousands, ''))
15421542
ret.append(rl)
15431543
return ret
15441544

pandas/io/tests/test_cparser.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from pandas import DataFrame, Series, Index, isnull, MultiIndex
2020
import pandas.io.parsers as parsers
2121
from pandas.io.parsers import (read_csv, read_table, read_fwf,
22-
TextParser)
22+
TextParser, TextFileReader)
2323
from pandas.util.testing import (assert_almost_equal, assert_frame_equal,
2424
assert_series_equal, network)
2525
import pandas.lib as lib
@@ -132,6 +132,16 @@ def test_integer_thousands(self):
132132

133133
expected = [123456, 12500]
134134
tm.assert_almost_equal(result[0], expected)
135+
136+
def test_integer_thousands_alt(self):
137+
data = '123.456\n12.500'
138+
139+
reader = TextFileReader(StringIO(data), delimiter=':',
140+
thousands='.', header=None)
141+
result = reader.read()
142+
143+
expected = [123456, 12500]
144+
tm.assert_almost_equal(result[0], expected)
135145

136146
def test_skip_bad_lines(self):
137147
# too many lines, see #2430 for why

0 commit comments

Comments
 (0)