years = list(range(2012, 2015))
yearly_month_stats = [dfts.xs(str(year)).groupby(lambda x: x.month).mean() for
    year in years]
df2 = pd.concat(yearly_month_stats, axis=1, keys=years)
Group by multiple time units in pandas data frame