df['mean_1year'] = df.groupby('type')['price'].rolling('365D').mean().reset_index(0,drop=True)