DataFrame.nsmallest()

pandas.DataFrame.nsmallest

DataFrame.nsmallest(n, columns, keep='first')

Get the rows of a DataFrame sorted by the n smallest values of columns.

New in version 0.17.0.

登录查看完整内容
Parameters:

n : int

Number of items to retrieve

columns : list or str

Column name or names to order by

keep : {‘first’, ‘last’, False}, default ‘first’

Where there are duplicate values: - first : take the first occurrence. - last : take the last occurrence.