modin.pandas.Series.nlargest¶
- Series.nlargest(n=5, keep='first') Series[source]¶
Return the largest n elements.
- Parameters:
n (int, default 5) – Return this many descending sorted values.
keep ({'first', 'last', 'all'}, 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.all: keep all occurrences. This can result in a Series of size larger than n.
- Returns:
The n largest values in the Series, sorted in decreasing order.
- Return type:
See also
Series.nsmallestGet the n smallest elements.
Series.sort_valuesSort Series by values.
Series.headReturn the first n rows.
Examples
The n largest elements where
n=5by default.The n largest elements where
n=3. Default keep value is ‘first’ so Malta will be kept.The n largest elements where
n=3and keeping the last duplicates. Brunei will be kept since it is the last with value 434000 based on the index order.The n largest elements where
n=3with all duplicates kept. Note that the returned Series has five elements due to the three duplicates.