Description
Again from mailing list:
Example:
data1 = '''date;value
01/05/2010;1
15/05/2010;2
31/05/2010;3
'''
df = pd.read_csv(StringIO(data1),sep=";",converters={'date':pd.datetools.dateutil.parser.parse})
print df.to_string()
Returns the first row wrong:
date value
0 2010-01-05 00:00:00 1
1 2010-05-15 00:00:00 2
2 2010-05-31 00:00:00 3
df = pd.read_csv(StringIO(data1),sep=";",converters={'date':lambda x: pd.datetools.dateutil.parser.parse(x, dayfirst=True)})
print df.to_string()
Returns the correct output
date value
0 2010-05-01 00:00:00 1
1 2010-05-15 00:00:00 2
2 2010-05-31 00:00:00 3
When using index_col and parse_dates, you can get also some of the dates that are wrong, some of them correct.
df = pd.read_csv(StringIO(data1),sep=";",index_col=[0],parse_dates=True)
print df.to_string()
Returns the first line also wrong:
value
date
2010-01-05 1
2010-05-15 2
2010-05-31 3