# -*- coding:utf-8 -*-
"""
作者:sunli
日期:2021年12月22日
"""

import matplotlib.pylab
import numpy as np
import pandas as pd

df = pd.Series(np.random.randn(12), index=pd.date_range('7/1/2016', freq='D', periods=12))
print(np.random.randn(12))
''' 定义滑动窗口'''
r = df.rolling(window=10)  # 窗口长度为10,可以计算这十个数的信息,比如最大值,均值等等
# r.max, r.median, r.std, r.skew, r.sum, r.var
print(r.mean())  # 计算均值

with open("Downs.txt", "w", encoding='UTF-8') as f1:
    f1.writelines(str(r.mean()))    #重点,将float转换为str