一、作用
消除周期变动和随机波动对时间序列的影响,显示事件的发展方向和趋势。加大期数会使平滑的效果更好。
二、类别
SMA:简单移动平均
EMA:指数加权移动平均,临近的期数会赋予更大的权重
#设置背景
plt.style.use('ggplot') # 灰色格子
plt.figure(figsize=(36,15))
sns.set_palette('Set2')
#画时间序列图
sns.lineplot(df0.order_id,df0.pitch,label="original")
sns.lineplot(df0['order_id'], df0["pitch"].rolling(window=5).mean(), label="SMA wave")
sns.lineplot(df0['order_id'], df0["pitch"].ewm(span=10).mean(), label="EMA wave")