这段代码:
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:
array([2012-07-31 02:00, 2012-07-31 02:15, 2012-07-31 02:30], dtype=object)
df2:
<class 'pandas.tseries.index.DatetimeIndex'>
[2012-07-31 02:00:00, ..., 2012-07-31 02:30:00]
Length: 3, Freq: None, Timezone: None
df1 和 df2 之间的差异是错误、功能还是我误解了什么?