I have a question regarding converting a tseries.period.PeriodIndex into a datetime.
I have a DataFrame which looks like this:
colors country time_month 2010-09 xxx xxx 2010-10 xxx xxx 2010-11 xxx xxx ...
time_month is the index.
type(df.index)
returns
class 'pandas.tseries.period.PeriodIndex'
When I try to use the df for a VAR analysis (http://statsmodels.sourceforge.net/devel/vector_ar.html#vector-autoregressions-tsa-vector-ar),
VAR(mdata)
returns:
Given a pandas object and the index does not contain dates
So apparently, Period is not recognized as a datetime. Now, my question is how to convert the index (time_month) into a datetime the VAR analysis can work with?
df.index = pandas.DatetimeIndex(df.index)
returns
cannot convert Int64Index->DatetimeIndex
Thank for your help!