时间序列分析(2)Python-基本统计量的计算

# -*- coding: utf-8 -*-
"""
Created on Fri Feb 17 11:30:57 2017

@author: yunjinqi

E-mail:yunjinqi@qq.com

Differentiate yourself in the world from anyone else.
"""
import pandas as pd
df=pd.read_excel('luowen.xls')
df.head()
df=df.iloc[::,8]
df.head()
df.shift(1).head()
rate=(df-df.shift(1))/df.shift(1)
rate=rate.dropna()
rate.head()
############################################计算数据的基本统计量:均值,方差,偏度,峰度等
import stats as sts
import numpy as np
len(rate)#长度
rate.mean()#均值
rate.std()#标准差
rate.var()#var
rate.describe()#描述
sts.skewness(rate)
sts.kurtosis(rate)
###引用别人写的
scores=rate
#集中趋势的度量  
print('求和:',np.sum(scores))  
print('个数:',len(scores))  
print('平均值:',np.mean(scores))  
print('中位数:',np.median(scores))  
print('众数:',sts.mode(scores))  
print('上四分位数',sts.quantile(scores,p=0.25))  
print('下四分位数',sts.quantile(scores,p=0.75))  
#离散趋势的度量  
print('最大值:',np.max(scores))  
print('最小值:',np.min(scores))  
print('极差:',np.max(scores)-np.min(scores))  
print('四分位差',sts.quantile(scores,p=0.75)-sts.quantile(scores,p=0.25))  
print('标准差:',np.std(scores))  
print('方差:',np.var(scores))  
print('离散系数:',np.std(scores)/np.mean(scores))  
#偏度与峰度的度量  
print('偏度:',sts.skewness(scores))  
print('峰度:',sts.kurtosis(scores)) 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

云金杞

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值