統計量分析--極差、標準差、變異係數、四分位數間距
阿新 • • 發佈:2019-01-04
#-*- 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)