统计量分析--极差、标准差、变异系数、四分位数间距
程序员文章站
2022-03-18 21:44:42
...
#-*- 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)