I'm using the pandas built-in DataReader to download data from the Fama-French data library. The dates are initially just integers in yyyymm format:
import pandas.io.data as web
ff = web.DataReader("F-F_Research_Data_Factors", "famafrench")[0]
ff.head()

I want to convert the index to a datetime, where the date is the last day of the month. Right now, I'm doing this:
ff.reset_index(inplace=True)
import calendar
def dateParser(dt):
yyyy = int(dt[0:4])
mm = int(dt[4:6])
dd = calendar.monthrange(yyyy,mm)[1] #last day of month
return pd.datetime(yyyy,mm,dd)
ff['date'] = ff['index'].astype(str).apply(dateParser)
ff.index = ff['date']
ff.drop(['index', 'date'], axis=1, inplace=True)
Is there a faster/more elegant way to accomplish this? For example, is there a way to apply dateParser directly to the index (perhaps inplace) so I don't have to reset_index first?