pandas计算方差,平均值,分位数,中位数

导入数据

import pandas as pd
movie= pd.read_csv('movie.csv')
movie.head()
Rank Title Genre Description Director ... Runtime (Minutes) Rating Votes Revenue (Millions) Metascore
0 1 Guardians of the Galaxy Action,Adventure,Sci-Fi A group of intergalactic criminals are forced ... James Gunn ... 121 8.1 757074 333.13 76.0
1 2 Prometheus Adventure,Mystery,Sci-Fi Following clues to the origin of mankind, a te... Ridley Scott ... 124 7.0 485820 126.46 65.0
2 3 Split Horror,Thriller Three girls are kidnapped by a man with a diag... M. Night Shyamalan ... 117 7.3 157606 138.12 62.0
3 4 Sing Animation,Comedy,Family In a city of humanoid animals, a hustling thea... Christophe Lourdelet ... 108 7.2 60545 270.32 59.0
4 5 Suicide Squad Action,Adventure,Fantasy A secret government agency recruits some of th... David Ayer ... 123 6.2 393727 325.02 40.0

5 rows × 12 columns

Rating的中位分位数 

# Rating的中位分位数
rating=movie.Rating
rating.quantile()
#6.8

分位数计算,百分之99.5的.

#分位数计算,百分之99.5的。
rating.quantile(0.995)
#8.6

求最小值、最大值、平均值、中位数、标准差、总和

rating.min()
#1.9

rating.max()
#9.0

rating.mean()
#6.723200000000003

rating.median()
#6.8

rating.std()
#0.9454287892779637

rating.sum()
#6723.2

打印描述信息

rating.describe()

count    1000.000000
mean        6.723200
std         0.945429
min         1.900000
25%         6.200000
50%         6.800000
75%         7.400000
max         9.000000
Name: Rating, dtype: float64

二分位数

rating.quantile(.2)
#6.0

各个十分之几分位数

rating.quantile([.1, .2, .3, .4, .5, .6, .7, .8, .9])

#显示结果
0.1    5.5
0.2    6.0
0.3    6.3
0.4    6.6
      ... 
0.6    7.0
0.7    7.3
0.8    7.5
0.9    7.9
Name: Rating, Length: 9, dtype: float64

 

你可能感兴趣的:(Pandas基础,python,数据分析,开发工具)