用法:
DataFrame.nlargest(n, columns, keep='first')
獲取按
columns
的第n個最大值排序的DataFrame的行- n:int
要返回的行數。
- columns:標簽或標簽列表
要排序的列標簽。
- keep:{‘first’, ‘last’},默認 ‘first’
有重複值的地方:
first
: 優先第一次出現last
:優先考慮最後出現的事件
- DataFrame
前
n
行按給定列按降序排列。
參數:
返回:
注意:
- 與 Pandas 的區別:
columns
中僅支持單列
例子:
>>> import cudf >>> df = cudf.DataFrame({'population': [59000000, 65000000, 434000, ... 434000, 434000, 337000, 11300, ... 11300, 11300], ... 'GDP': [1937894, 2583560 , 12011, 4520, 12128, ... 17036, 182, 38, 311], ... 'alpha-2': ["IT", "FR", "MT", "MV", "BN", ... "IS", "NR", "TV", "AI"]}, ... index=["Italy", "France", "Malta", ... "Maldives", "Brunei", "Iceland", ... "Nauru", "Tuvalu", "Anguilla"]) >>> df population GDP alpha-2 Italy 59000000 1937894 IT France 65000000 2583560 FR Malta 434000 12011 MT Maldives 434000 4520 MV Brunei 434000 12128 BN Iceland 337000 17036 IS Nauru 11300 182 NR Tuvalu 11300 38 TV Anguilla 11300 311 AI >>> df.nlargest(3, 'population') population GDP alpha-2 France 65000000 2583560 FR Italy 59000000 1937894 IT Malta 434000 12011 MT >>> df.nlargest(3, 'population', keep='last') population GDP alpha-2 France 65000000 2583560 FR Italy 59000000 1937894 IT Brunei 434000 12128 BN
相關用法
- Python cudf.DataFrame.notna用法及代碼示例
- Python cudf.DataFrame.notnull用法及代碼示例
- Python cudf.DataFrame.nans_to_nulls用法及代碼示例
- Python cudf.DataFrame.nsmallest用法及代碼示例
- Python cudf.DataFrame.ne用法及代碼示例
- Python cudf.DataFrame.mod用法及代碼示例
- Python cudf.DataFrame.isin用法及代碼示例
- Python cudf.DataFrame.rmul用法及代碼示例
- Python cudf.DataFrame.apply用法及代碼示例
- Python cudf.DataFrame.exp用法及代碼示例
- Python cudf.DataFrame.drop用法及代碼示例
- Python cudf.DataFrame.where用法及代碼示例
- Python cudf.DataFrame.median用法及代碼示例
- Python cudf.DataFrame.to_pandas用法及代碼示例
- Python cudf.DataFrame.take用法及代碼示例
- Python cudf.DataFrame.tail用法及代碼示例
- Python cudf.DataFrame.rfloordiv用法及代碼示例
- Python cudf.DataFrame.equals用法及代碼示例
- Python cudf.DataFrame.head用法及代碼示例
- Python cudf.DataFrame.count用法及代碼示例
注:本文由純淨天空篩選整理自rapids.ai大神的英文原創作品 cudf.DataFrame.nlargest。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。