monthly_sales['moving_avg_sales'] = monthly_sales.iloc[:,2].rolling(window=3).mean()

monthly_sales['moving'] = monthly_sales.groupby('category')['actual_sales'].transform(lambda x: x.rolling(10, 1).mean())
monthly_sales['moving1'] = monthly_sales.groupby(['category', 'distributorid'])['actual_sales'].transform(lambda x: x.rolling(3).mean())