pandas.DataFrame.nsmallest
pandas 3.1.1 · DataFrame · method
Get the n smallest observations.
Call syntax
DataFrame.nsmallest(n, columns, keep='first')Run the example
Edit the example and select Run Python to see the result.
Parameters
| Parameter | Requirement | Accepted values and behavior |
|---|---|---|
n |
Required Positional or keyword |
int Choose how many entries or positions to use. |
columns |
Required Positional or keyword |
list or str Supply column labels or control how columns are handled. |
keep |
Optional Positional or keyword Default 'first' |
{'first', 'last', 'all'} Choose which occurrence to retain when values are duplicated or tied. |
Returns
DataFrame