read_csv(parse_dates=True) failure #1816

Closed
lodagro opened this Issue Aug 27, 2012 · 6 comments

Projects

None yet

3 participants

@lodagro
Python for Data member

from stackoverflow

import pandas as pd
from StringIO import StringIO

data = "date,c1\n2012-07-31 02:00,1.1\n2012-07-31 02:15,2.2\n2012-07-31 02:30,3.3\n"

df1 = pd.read_csv(StringIO(data),parse_dates=True).set_index(('date'))
df2 = pd.read_csv(StringIO(data),parse_dates=[0] ).set_index(('date'))

print "df1:\n{index}".format(index=df1.index)
print "df2:\n{index}".format(index=df2.index)

df1 has a index of dtype object.

@changhiskhan
Python for Data member

If parse_dates=True, the reader will attempt to parse the index as datetime (see documentation: http://pandas.pydata.org/pandas-docs/stable/io.html). I'll change the docstring for now.

@lodagro
Python for Data member

One can indeed look at it from two ways, and fix by updating the docstring :-)

@changhiskhan
Python for Data member
@lodagro
Python for Data member

Oh, for me it`s fine to update the docstring!

@changhiskhan
Python for Data member

Closing for now. Can revisit later if it makes sense to have the parser try to parse everything as datetime (performance hit will probably be too much?)

@valentas-kurauskas

very non-intuitive..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment