大 pandas 显示错误的百分位数吗? [英] Is pandas showing the wrong percentile?
问题描述
我正在此处处理这个 WNBA 数据集.我正在分析 Height
变量,下表显示记录的每个高度值的频率、累积百分比和累积频率:
I'm working with this WNBA dataset here. I'm analyzing the Height
variable, and below is a table showing frequency, cumulative percentage, and cumulative frequency for each height value recorded:
从表中我可以很容易地得出结论,第一个四分位数(第 25 个百分位数)不能大于 175.
From the table I can easily conclude that the first quartile (the 25th percentile) cannot be larger than 175.
但是,当我使用 Series.describe()
时,我被告知第 25 个百分位数是 176.5.为什么会这样?
However, when I use Series.describe()
, I'm told that the 25th percentile is 176.5. Why is that so?
wnba.Height.describe()
count 143.000000
mean 184.566434
std 8.685068
min 165.000000
25% 176.500000
50% 185.000000
75% 191.000000
max 206.000000
Name: Height, dtype: float64
推荐答案
有多种估计分位数的方法.
175.0 与 176.5 与两种不同的方法有关:
There are various ways to estimate the quantiles.
The 175.0 vs 176.5 relates to two different methods:
- 包括 Q1(得出 176.5)和
- 不包括 Q1(给出 175.0).
估计不同如下
#1
h = (N − 1)*p + 1 #p being 0.25 in your case
Est_Quantile = x⌊h⌋ + (h − ⌊h⌋)*(x⌊h⌋ + 1 − x⌊h⌋)
#2
h = (N + 1)*p
x⌊h⌋ + (h − ⌊h⌋)*(x⌊h⌋ + 1 − x⌊h⌋)
这篇关于大 pandas 显示错误的百分位数吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!