@@ -1277,6 +1277,7 @@ def __init__(self, f, **kwds):
1277
1277
self ._make_reader (f )
1278
1278
else :
1279
1279
self .data = f
1280
+
1280
1281
self .columns = self ._infer_columns ()
1281
1282
1282
1283
# we are processing a multi index column
@@ -1300,6 +1301,38 @@ def __init__(self, f, **kwds):
1300
1301
self .index_names = index_names
1301
1302
self ._first_chunk = True
1302
1303
1304
+ if self .parse_dates :
1305
+ self ._no_thousands_columns = self ._set_no_thousands_columns ()
1306
+ else :
1307
+ self ._no_thousands_columns = None
1308
+
1309
+ def _set_no_thousands_columns (self ):
1310
+ # Create a set of column ids that are not to be stripped of thousands operators.
1311
+ noconvert_columns = set ()
1312
+
1313
+ def _set (x ):
1314
+ if com .is_integer (x ):
1315
+ noconvert_columns .add (x )
1316
+ else :
1317
+ noconvert_columns .add (self .columns .index (x ))
1318
+
1319
+ if isinstance (self .parse_dates , list ):
1320
+ for val in self .parse_dates :
1321
+ if isinstance (val , list ):
1322
+ for k in val :
1323
+ _set (k )
1324
+ else :
1325
+ _set (val )
1326
+
1327
+ elif isinstance (self .parse_dates , dict ):
1328
+ for val in self .parse_dates .values ():
1329
+ if isinstance (val , list ):
1330
+ for k in val :
1331
+ _set (k )
1332
+ else :
1333
+ _set (val )
1334
+ return noconvert_columns
1335
+
1303
1336
def _make_reader (self , f ):
1304
1337
sep = self .delimiter
1305
1338
@@ -1508,7 +1541,6 @@ def _next_line(self):
1508
1541
line = next (self .data )
1509
1542
1510
1543
line = self ._check_comments ([line ])[0 ]
1511
- line = self ._check_thousands ([line ])[0 ]
1512
1544
1513
1545
self .pos += 1
1514
1546
self .buf .append (line )
@@ -1540,9 +1572,10 @@ def _check_thousands(self, lines):
1540
1572
ret = []
1541
1573
for l in lines :
1542
1574
rl = []
1543
- for x in l :
1575
+ for i , x in enumerate ( l ) :
1544
1576
if (not isinstance (x , compat .string_types ) or
1545
1577
self .thousands not in x or
1578
+ (self ._no_thousands_columns and i in self ._no_thousands_columns ) or
1546
1579
nonnum .search (x .strip ())):
1547
1580
rl .append (x )
1548
1581
else :
@@ -1616,7 +1649,6 @@ def _rows_to_cols(self, content):
1616
1649
raise AssertionError ()
1617
1650
1618
1651
if col_len != zip_len and self .index_col is not False :
1619
- row_num = - 1
1620
1652
i = 0
1621
1653
for (i , l ) in enumerate (content ):
1622
1654
if len (l ) != col_len :
0 commit comments