cudf.Series.nlargest#
- Series.nlargest(n=5, keep='first')#
Returns a new Series of the n largest element.
- Parameters
- nint, default 5
Return this many descending sorted values.
- keep{‘first’, ‘last’}, default ‘first’
When there are duplicate values that cannot all fit in a Series of n elements:
first
: return the first n occurrences in order of appearance.last
: return the last n occurrences in reverse order of appearance.
- Returns
- Series
The n largest values in the Series, sorted in decreasing order.
Examples
>>> import cudf >>> countries_population = {"Italy": 59000000, "France": 65000000, ... "Malta": 434000, "Maldives": 434000, ... "Brunei": 434000, "Iceland": 337000, ... "Nauru": 11300, "Tuvalu": 11300, ... "Anguilla": 11300, "Montserrat": 5200} >>> series = cudf.Series(countries_population) >>> series Italy 59000000 France 65000000 Malta 434000 Maldives 434000 Brunei 434000 Iceland 337000 Nauru 11300 Tuvalu 11300 Anguilla 11300 Montserrat 5200 dtype: int64 >>> series.nlargest() France 65000000 Italy 59000000 Malta 434000 Maldives 434000 Brunei 434000 dtype: int64 >>> series.nlargest(3) France 65000000 Italy 59000000 Malta 434000 dtype: int64 >>> series.nlargest(3, keep='last') France 65000000 Italy 59000000 Brunei 434000 dtype: int64