diff --git a/doc/source/release.rst b/doc/source/release.rst index d747505593c94..4224880d3fde0 100644 --- a/doc/source/release.rst +++ b/doc/source/release.rst @@ -429,7 +429,9 @@ Bug Fixes ``ascending`` was being interpreted as ``True`` (:issue:`4839`, :issue:`4846`) - Fixed ``Panel.tshift`` not working. Added `freq` support to ``Panel.shift`` (:issue:`4853`) - + - Fix an issue in TextFileReader w/ Python engine (i.e. PythonParser) + with thousands != "," (:issue:`4596`) + pandas 0.12.0 ------------- diff --git a/pandas/io/parsers.py b/pandas/io/parsers.py index 5554bef4acf98..c4ea76585df83 100644 --- a/pandas/io/parsers.py +++ b/pandas/io/parsers.py @@ -1538,7 +1538,7 @@ def _check_thousands(self, lines): nonnum.search(x.strip())): rl.append(x) else: - rl.append(x.replace(',', '')) + rl.append(x.replace(self.thousands, '')) ret.append(rl) return ret diff --git a/pandas/io/tests/test_cparser.py b/pandas/io/tests/test_cparser.py index d5f62cf909513..8db9c7de6cbcd 100644 --- a/pandas/io/tests/test_cparser.py +++ b/pandas/io/tests/test_cparser.py @@ -19,7 +19,7 @@ from pandas import DataFrame, Series, Index, isnull, MultiIndex import pandas.io.parsers as parsers from pandas.io.parsers import (read_csv, read_table, read_fwf, - TextParser) + TextParser, TextFileReader) from pandas.util.testing import (assert_almost_equal, assert_frame_equal, assert_series_equal, network) import pandas.lib as lib @@ -132,6 +132,16 @@ def test_integer_thousands(self): expected = [123456, 12500] tm.assert_almost_equal(result[0], expected) + + def test_integer_thousands_alt(self): + data = '123.456\n12.500' + + reader = TextFileReader(StringIO(data), delimiter=':', + thousands='.', header=None) + result = reader.read() + + expected = [123456, 12500] + tm.assert_almost_equal(result[0], expected) def test_skip_bad_lines(self): # too many lines, see #2430 for why