1. 首页
  2. Pandas

pandas计算某一列的移动平均值M5

统计移动平均M5,M10

df_v2['m1'] = df_v2['打赏用户数'].rolling(1).mean()
df_v2['m3'] = df_v2['打赏用户数'].rolling(3).mean()
df_v2['m7'] = df_v2['打赏用户数'].rolling(7).mean()
df_v2['pct_pop'] = df_v2['打赏用户数'].pct_change()
df_v2['pct_yoy'] = df_v2['打赏用户数'].pct_change(periods=7)
df_v2

pandas计算某一列的移动平均值M5

参考

 

[python – Rolling Mean on pandas on a specific column – Stack Overflow](https://stackoverflow.com/questions/43437657/rolling-mean-on-pandas-on-a-specific-column )

[python – Rolling Mean on pandas on a specific column – Stack Overflow](https://stackoverflow.com/questions/43437657/rolling-mean-on-pandas-on-a-specific-column )

发表评论

登录后才能评论