Skip to content

Commit 859aa2c

Browse files
committed
put date parsing after individual column inferencing so integers can be parsed better
1 parent cfe674e commit 859aa2c

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

pandas/io/parsers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -807,12 +807,12 @@ def get_chunk(self, rows=None):
807807
col = self.columns[col]
808808
data[col] = lib.map_infer(data[col], f)
809809

810+
data = _convert_to_ndarrays(data, self.na_values, self.verbose)
811+
810812
columns = list(self.columns)
811813
if self.parse_dates is not None:
812814
data, columns = self._process_date_conversion(data)
813815

814-
data = _convert_to_ndarrays(data, self.na_values, self.verbose)
815-
816816
df = DataFrame(data=data, columns=columns, index=index)
817817
if self._has_complex_date_col and self.index_col is not None:
818818
if not self._name_processed:
@@ -1129,7 +1129,9 @@ def _concat_date_cols(date_cols):
11291129
return date_cols[0]
11301130

11311131
# stripped = [map(str.strip, x) for x in date_cols]
1132-
return np.array([' '.join(x) for x in zip(*date_cols)], dtype=object)
1132+
rs = np.array([' '.join([str(y) for y in x])
1133+
for x in zip(*date_cols)], dtype=object)
1134+
return rs
11331135

11341136

11351137
class FixedWidthReader(object):

pandas/io/tests/test_date_converters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_parse_date_fields(self):
5757
expected = np.array([datetime(2007, 1, 3), datetime(2008, 2, 4)])
5858
self.assert_((result == expected).all())
5959

60-
data = "year, month, day, a\n 2001, 01, 10, 10.\n 2001, 02, 1, 11."
60+
data = "year, month, day, a\n 2001 , 01 , 10 , 10.\n 2001 , 02 , 1 , 11."
6161
datecols = {'ymd': [0, 1, 2]}
6262
df = read_table(StringIO(data), sep=',', header=0,
6363
parse_dates=datecols,

0 commit comments

Comments
 (0)