pandas.core.groupby.SeriesGroupBy.nsmallest
- 
SeriesGroupBy.nsmallest
- 
Return the smallest nelements.Parameters: n : int Return this many ascending sorted values - 
keep : {‘first’, ‘last’, False}, default ‘first’
- 
Where there are duplicate values: - first: take the first occurrence. -last: take the last occurrence.
 Returns: bottom_n : Series The n smallest values in the Series, in sorted order NotesFaster than .sort_values().head(n)for smallnrelative to the size of theSeriesobject.Examples>>> import pandas as pd >>> import numpy as np >>> s = pd.Series(np.random.randn(10**6)) >>> s.nsmallest(10) # only sorts up to the N requested 288532 -4.954580 732345 -4.835960 64803 -4.812550 446457 -4.609998 501225 -4.483945 669476 -4.472935 973615 -4.401699 621279 -4.355126 773916 -4.347355 359919 -4.331927 dtype: float64 
- 
    © 2008–2012, AQR Capital Management, LLC, Lambda Foundry, Inc. and PyData Development Team
Licensed under the 3-clause BSD License.
    https://pandas.pydata.org/pandas-docs/version/0.20.3/generated/pandas.core.groupby.SeriesGroupBy.nsmallest.html