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

简介: 时间序列分析(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)) 
目录
相关文章
|
1天前
|
Python
python计算线段角度
python计算线段角度
2 0
|
6天前
|
语音技术 开发者 Python
python之pyAudioAnalysis:音频特征提取分析文档示例详解
python之pyAudioAnalysis:音频特征提取分析文档示例详解
11 0
|
6天前
|
数据可视化 大数据 Python
python大数据分析处理
python大数据分析处理
11 0
|
6天前
|
机器学习/深度学习 人工智能 大数据
AI时代Python金融大数据分析实战:ChatGPT让金融大数据分析插上翅膀
AI时代Python金融大数据分析实战:ChatGPT让金融大数据分析插上翅膀
|
8天前
|
机器学习/深度学习 自然语言处理 算法
Python遗传算法GA对长短期记忆LSTM深度学习模型超参数调优分析司机数据|附数据代码
Python遗传算法GA对长短期记忆LSTM深度学习模型超参数调优分析司机数据|附数据代码
|
8天前
|
Python Perl
Python中的字符串分析:判断字符串中是否包含字母
Python中的字符串分析:判断字符串中是否包含字母
10 0
|
8天前
|
机器学习/深度学习 数据可视化 决策智能
Python中使用Gradient Boosting Decision Trees (GBDT)进行特征重要性分析
Python中使用Gradient Boosting Decision Trees (GBDT)进行特征重要性分析
22 0
|
8天前
|
机器学习/深度学习 Python
python实现判别分析
python实现判别分析
12 1
|
8天前
|
机器学习/深度学习 存储 算法
Python套索回归lasso、SCAD、LARS分析棒球运动员薪水3个实例合集|附数据代码
Python套索回归lasso、SCAD、LARS分析棒球运动员薪水3个实例合集|附数据代码
|
8天前
|
机器学习/深度学习 数据采集 数据可视化
利用Python进行历史数据预测:从入门到实践的两个案例分析
利用Python进行历史数据预测:从入门到实践的两个案例分析
22 1