時系列でのウィンドウをスライディング[]

%matplotlib inline 
import matplotlib.pylab
import numpy as np
import pandas as pd
df = pd.Series(np.random.randn(600), index = pd.date_range('7/1/2016', freq = 'D', periods = 600))
r = df.rolling(window = 10)
#r.max, r.median, r.std, r.skew, r.sum, r.var
print(r.mean())

NaNの2016年7月1日
2016年7月2日NaNの
2016年7月3日NaNの
2016年7月4日NaNの
2016年7月5日NaNの
2016年7月6日NaNの
2016年7月7日NaNの
2016年7月8日のNaN
2016- 07-09のNaN
2016年7月10日0.300133
2016年7月11日0.284780
2016年7月12日0.252831
2016年7月13日0.220699
2016年7月14日0.167137
2016年7月15日0.018593
2016年7月16日-0.061414
2016から07 -0.134593 -17
2016年7月18日-0.153333
2016年7月19日-0.218928
2016年7月20日-0.169426
2016年7月21日-0.219747
2016年7月22日-0.181266
2016年7月23日-0.173674
2016-07- 24 -0.130629
2016年7月25日-0.166730
2016年7月26日-0.233044
2016年7月27日-0.256642
2016年7月28日-0.280738
2016年7月29日-0.289893
2016年7月30日-0.379625
...
2018年1月22日-0.211467
2018年1月23日0.034996
2018年1月24日-0.105910
2018年1月25日-0.145774
2018 -01-26 -0.089320
2018年1月27日-0.164370
2018年1月28日-0.110892
2018年1月29日-0.205786
2018年1月30日-0.101162
2018年1月31日-0.034760
2018年2月1日0.229333
2018から02 -02 0.043741
2018年2月3日0.052837
2018年2月4日0.057746
2018年2月5日-0.071401
2018年2月6日-0.011153
2018年2月7日-0.045737
2018年2月8日-0.021983
2018年2月9日-0.196715
2018年2月10日-0.063721
2018年2月11日-0.289452
2018年2月12日-0.050946
2018年2月13日-0.047014
2018年2月14日0.048754
2018年2月15日0.143949
2018年2月16日0.424823
2018年2月17日0.361878
2018年2月18日0.363235
2018年2月19日0.517436
2018年2月20日0.368020
のFreq :D、長さ:600、DTYPE:のfloat64

import matplotlib.pyplot as plt
%matplotlib inline

plt.figure(figsize=(15, 5))

df.plot(style='r--')
df.rolling(window=10).mean().plot(style='b')

ここに画像を挿入説明

公開された116元の記事 ウォン称賛10 ビュー1346

おすすめ

転載: blog.csdn.net/weixin_44727383/article/details/105007561