modin.pandas.Series.nsmallest¶
- Series.nsmallest(n=5, keep='first') Series[source]¶
Return the smallest n elements.
- Parameters:
n (int, default 5) – Return this many ascending 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 smallest values in the Series, sorted in increasing order.
- Return type:
See also
Series.nlargestGet the n largest elements.
Series.sort_valuesSort Series by values.
Series.headReturn the first n rows.
Examples
The n smallest elements where
n=5by default.The n smallest elements where
n=3. Default keep value is ‘first’ so Nauru and Tuvalu will be kept.The n smallest elements where
n=3and keeping the last duplicates. Anguilla and Tuvalu will be kept since they are the last with value 11300 based on the index order.The n smallest elements where
n=3with all duplicates kept. Note that the returned Series has four elements due to the three duplicates.