Series.
quantile
(
q=0.5,
interpolation='linear'
)
| Parameters: | q : float or array-like, default 0.5 (50% quantile)
interpolation : {‘linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’}
|
|---|---|
| Returns: | quantile : float or Series
|
- q : float or array-like, default 0.5 (50% quantile 即中位数-第2四分位数)
0 <= q <= 1, the quantile(s) to compute
- axis : {0, 1, ‘index’, ‘columns’} (default 0)
0 or ‘index’ for row-wise, 1 or ‘columns’ for column-wise
- interpolation(插值方法) : {‘linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’}
当选中的分为点位于两个数数据点 i and j 之间时:
linear: i + (j - i) * fraction, fraction由计算得到的pos的小数部分(可以通过下面一个例子来理解这个fraction);
lower: i.
higher: j.
nearest: i or j whichever is nearest.
midpoint: (i + j) / 2.
统计学上的四分为函数
原则上q是可以取0到1之间的任意值的。但是有一个四分位数是q分位数中较为有名的。
所谓四分位数;即把数值由小到大排列并分成四等份,处于三个分割点位置的数值就是四分位数。
- 第1四分位数 (Q1),又称“较小四分位数”,等于该样本中所有数值由小到大排列后第25%的数字。
- 第2四分位数 (Q2),又称“中位数”,等于该样本中所有数值由小到大排列后第50%的数字。
- 第3四分位数 (Q3),又称“较大四分位数”,等于该样本中所有数值由小到大排列后第75%的数字。
第3四分位数与第1四分位数的差距又称四分位距(InterQuartile Range,IQR)
当q=0.25 0.5 0.75 时,就是在计算四分位数。Return value at the given quantile, a la numpy.percentile
DataFrame. quantile ( q=0.5, axis=0, numeric_only=True )| Parameters: | q : float or array-like, default 0.5 (50% quantile)
axis : {0, 1, ‘index’, ‘columns’} (default 0)
|
|---|---|
| Returns: | quantiles : Series or DataFrame
|
Return values at the given quantile over requested axis, a la numpy.percentile.
相关阅读:
https://www.zhihu.com/question/58421946
本文介绍了Python中的quantile()函数,用于计算指定的分位数。重点讲解了参数q、axis和interpolation的含义,以及四分位数的概念,包括Q1、Q2(中位数)和Q3,并提到了四分位距IQR的重要性。此外,还解释了不同插值方法对分位数计算的影响。
1984

被折叠的 条评论
为什么被折叠?



