常用统计量分析
import pandas as pd
df1=pd.read_csv("./data/data1.csv",encoding='gbk',index_col='产品编码')
print(df1.head())
#获得数据
print(len(df1))
print(df1.index.size)
#求均值mean 中位数 median
print(df1['供应商进货价'].mean())
print(df1['供应商进货价'].median())
#众数 出现最多的数
from pandas import Series
data=Series([7,9,8,9,7,6])
data.mode()
#最值 min() ,max()
print(df1.min())
print(df1.max())
#极差=最大-最小
print("供应商进货价极差:{}".format(df1['供应商进货价'].max()-df1['供应商进货价'].min()))
#标准差:std 方差:var
print('供应商进货价标准差:{:.2f}'.format(df1['供应商进货价'].std()))
print('供应商进货价方差:{:.2f}'.format(df1['供应商进货价'].var()))
#描述性统计分析
statistics=df1.describe()
#loc , iloc, 极差,增加行
statistics.loc['mean']
statistics.iloc[1]
statistics['range']=statistics.loc['max']-statistics.loc['min']
print(statistics)