Skip to content

Commit

Permalink
BUG: don't be too aggressive with int conversion parsing MultiIndex, GH
Browse files Browse the repository at this point in the history
  • Loading branch information
wesm committed Oct 25, 2011
1 parent 84477de commit ef6a7b3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,11 @@ def get_chunk(self, rows=None):
index = Index(_convert_types(index, self.na_values),
name=self.index_name)
else:
arrays = _maybe_convert_int_mindex(index, self.parse_dates,
self.date_parser)
arrays = []
for arr in index:
if self.parse_dates:
arr = lib.try_parse_dates(arr, parser=self.date_parser)
arrays.append(_convert_types(arr, self.na_values))
index = MultiIndex.from_arrays(arrays, names=self.index_name)
else:
index = Index(np.arange(len(content)))
Expand Down
15 changes: 15 additions & 0 deletions pandas/io/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,21 @@ def test_multi_index_no_level_names(self):
df2 = read_csv(StringIO(data2))
assert_frame_equal(df2, df)

def test_multi_index_parse_dates(self):
data = """index1,index2,A,B,C
20090101,one,a,1,2
20090101,two,b,3,4
20090101,three,c,4,5
20090102,one,a,1,2
20090102,two,b,3,4
20090102,three,c,4,5
20090103,one,a,1,2
20090103,two,b,3,4
20090103,three,c,4,5
"""
df = read_csv(StringIO(data), index_col=[0, 1], parse_dates=True)
self.assert_(isinstance(df.index.levels[0][0], datetime))

class TestParseSQL(unittest.TestCase):

def test_convert_sql_column_floats(self):
Expand Down

0 comments on commit ef6a7b3

Please sign in to comment.