统计量分析--极差、标准差、变异系数、四分位数间距

#-*- coding: utf-8 -*-
#餐饮销量数据统计量分析
import pandas as pd

catering_sale = 'catering_sale.xls' #餐饮数据
data = pd.read_excel(catering_sale, index_col = '日期') #读取数据,指定“日期”列为索引列
data = data[(data['销量'] > 400)&(data['销量'] < 5000)] #过滤异常数据
statistics = data.describe() #保存基本统计量

statistics.loc['range'] = statistics.loc['max']-statistics.loc['min'] #极差
statistics.loc['var'] = statistics.loc['std']/statistics.loc['mean'] #变异系数
statistics.loc['dis'] = statistics.loc['75%']-statistics.loc['25%'] #四分位数间距

print(statistics)

结果:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章