用法:
Series.quantile(q=0.5, interpolation='linear')
返回給定分位數的值。
- q:float 或 array-like,默認 0.5(50% 分位數)
要計算的分位數,可以在範圍內:0 <= q <= 1。
- interpolation:{‘linear’, ‘lower’, ‘higher’, ‘midpoint’, ‘nearest’}
當所需的分位數位於兩個數據點
i
和j
之間時,此可選參數指定要使用的插值方法:linear:
i + (j - i) * fraction
, wherefraction
is the fractional part of the index surrounded byi
andj
.lower:
i
.higher:
j
.nearest:
i
orj
whichever is nearest.midpoint:(
i
+j
) / 2.
- 浮點數或係列
如果
q
是一個數組,則將返回一個係列,其中索引為q
,值是分位數,否則將返回一個浮點數。
參數:
返回:
例子:
>>> s = pd.Series([1, 2, 3, 4]) >>> s.quantile(.5) 2.5 >>> s.quantile([.25, .5, .75]) 0.25 1.75 0.50 2.50 0.75 3.25 dtype:float64
相關用法
- Python pandas.Series.add_prefix用法及代碼示例
- Python pandas.Series.map用法及代碼示例
- Python pandas.Series.max用法及代碼示例
- Python pandas.Series.str.isdecimal用法及代碼示例
- Python pandas.Series.str.get用法及代碼示例
- Python pandas.Series.to_csv用法及代碼示例
- Python pandas.Series.dt.day_name用法及代碼示例
- Python pandas.Series.sample用法及代碼示例
- Python pandas.Series.head用法及代碼示例
- Python pandas.Series.eq用法及代碼示例
- Python pandas.Series.plot.line用法及代碼示例
- Python pandas.Series.to_pickle用法及代碼示例
- Python pandas.Series.between_time用法及代碼示例
- Python pandas.Series.reindex_like用法及代碼示例
- Python pandas.Series.dt.is_year_end用法及代碼示例
- Python pandas.Series.repeat用法及代碼示例
- Python pandas.Series.str.replace用法及代碼示例
- Python pandas.Series.update用法及代碼示例
- Python pandas.Series.iat用法及代碼示例
- Python pandas.Series.divide用法及代碼示例
注:本文由純淨天空篩選整理自pandas.pydata.org大神的英文原創作品 pandas.Series.quantile。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。