用法:
Series.nsmallest(n=5, keep='first')
返回
n
最小元素的新係列。- n:整數,默認 5
返回這麽多升序排序的值。
- keep:{‘first’, ‘last’},默認 ‘first’
當有重複值不能全部放入
n
元素係列時:first
:按出現順序返回第一個n
出現。last
:以相反的出現順序返回最後出現的n
。
- Series
係列中的
n
最小值,按升序排序。
參數:
返回:
例子:
>>> import cudf >>> countries_population = {"Italy": 59000000, "France": 65000000, ... "Brunei": 434000, "Malta": 434000, ... "Maldives": 434000, "Iceland": 337000, ... "Nauru": 11300, "Tuvalu": 11300, ... "Anguilla": 11300, "Montserrat": 5200} >>> s = cudf.Series(countries_population) >>> s Italy 59000000 France 65000000 Brunei 434000 Malta 434000 Maldives 434000 Iceland 337000 Nauru 11300 Tuvalu 11300 Anguilla 11300 Montserrat 5200 dtype: int64
n
最小元素,默認為n=5
。>>> s.nsmallest() Montserrat 5200 Nauru 11300 Tuvalu 11300 Anguilla 11300 Iceland 337000 dtype: int64
n
最小元素,其中n=3
。默認keep
值為 ‘first’,因此將保留瑙魯和圖瓦盧。>>> s.nsmallest(3) Montserrat 5200 Nauru 11300 Tuvalu 11300 dtype: int64
n
最小元素,其中n=3
並保留最後一個重複項。安圭拉和圖瓦盧將被保留,因為它們是最後一個,基於索引順序的值為 11300。>>> s.nsmallest(3, keep='last') Montserrat 5200 Anguilla 11300 Tuvalu 11300 dtype: int64
相關用法
- Python cudf.Series.nlargest用法及代碼示例
- Python cudf.Series.notnull用法及代碼示例
- Python cudf.Series.nunique用法及代碼示例
- Python cudf.Series.nans_to_nulls用法及代碼示例
- Python cudf.Series.notna用法及代碼示例
- Python cudf.Series.ne用法及代碼示例
- Python cudf.Series.ceil用法及代碼示例
- Python cudf.Series.update用法及代碼示例
- Python cudf.Series.max用法及代碼示例
- Python cudf.Series.head用法及代碼示例
- Python cudf.Series.reindex用法及代碼示例
- Python cudf.Series.interleave_columns用法及代碼示例
- Python cudf.Series.min用法及代碼示例
- Python cudf.Series.to_frame用法及代碼示例
- Python cudf.Series.mask用法及代碼示例
- Python cudf.Series.isnull用法及代碼示例
- Python cudf.Series.rmod用法及代碼示例
- Python cudf.Series.map用法及代碼示例
- Python cudf.Series.data用法及代碼示例
- Python cudf.Series.lt用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.Series.nsmallest。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。