@@ -3390,15 +3390,6 @@ def sortlevel(self, level=0, axis=0, ascending=True, inplace=False,
33903390 return self .sort_index (level = level , axis = axis , ascending = ascending ,
33913391 inplace = inplace , sort_remaining = sort_remaining )
33923392
3393- def _nsorted (self , columns , n , method , keep ):
3394- if not is_list_like (columns ):
3395- columns = [columns ]
3396- columns = list (columns )
3397- ser = getattr (self [columns [0 ]], method )(n , keep = keep )
3398- ascending = dict (nlargest = False , nsmallest = True )[method ]
3399- return self .loc [ser .index ].sort_values (columns , ascending = ascending ,
3400- kind = 'mergesort' )
3401-
34023393 def nlargest (self , n , columns , keep = 'first' ):
34033394 """Get the rows of a DataFrame sorted by the `n` largest
34043395 values of `columns`.
@@ -3431,7 +3422,7 @@ def nlargest(self, n, columns, keep='first'):
34313422 1 10 b 2
34323423 2 8 d NaN
34333424 """
3434- return self . _nsorted ( columns , n , 'nlargest' , keep )
3425+ return algos . select_n_frame ( self , columns , n , 'nlargest' , keep )
34353426
34363427 def nsmallest (self , n , columns , keep = 'first' ):
34373428 """Get the rows of a DataFrame sorted by the `n` smallest
@@ -3465,7 +3456,7 @@ def nsmallest(self, n, columns, keep='first'):
34653456 0 1 a 1
34663457 2 8 d NaN
34673458 """
3468- return self . _nsorted ( columns , n , 'nsmallest' , keep )
3459+ return algos . select_n_frame ( self , columns , n , 'nsmallest' , keep )
34693460
34703461 def swaplevel (self , i = - 2 , j = - 1 , axis = 0 ):
34713462 """
0 commit comments