@@ -3337,15 +3337,6 @@ def sortlevel(self, level=0, axis=0, ascending=True, inplace=False,
33373337 return self .sort_index (level = level , axis = axis , ascending = ascending ,
33383338 inplace = inplace , sort_remaining = sort_remaining )
33393339
3340- def _nsorted (self , columns , n , method , keep ):
3341- if not is_list_like (columns ):
3342- columns = [columns ]
3343- columns = list (columns )
3344- ser = getattr (self [columns [0 ]], method )(n , keep = keep )
3345- ascending = dict (nlargest = False , nsmallest = True )[method ]
3346- return self .loc [ser .index ].sort_values (columns , ascending = ascending ,
3347- kind = 'mergesort' )
3348-
33493340 def nlargest (self , n , columns , keep = 'first' ):
33503341 """Get the rows of a DataFrame sorted by the `n` largest
33513342 values of `columns`.
@@ -3378,7 +3369,7 @@ def nlargest(self, n, columns, keep='first'):
33783369 1 10 b 2
33793370 2 8 d NaN
33803371 """
3381- return self . _nsorted ( columns , n , 'nlargest' , keep )
3372+ return algos . select_n_frame ( self , columns , n , 'nlargest' , keep )
33823373
33833374 def nsmallest (self , n , columns , keep = 'first' ):
33843375 """Get the rows of a DataFrame sorted by the `n` smallest
@@ -3412,7 +3403,7 @@ def nsmallest(self, n, columns, keep='first'):
34123403 0 1 a 1
34133404 2 8 d NaN
34143405 """
3415- return self . _nsorted ( columns , n , 'nsmallest' , keep )
3406+ return algos . select_n_frame ( self , columns , n , 'nsmallest' , keep )
34163407
34173408 def swaplevel (self , i = - 2 , j = - 1 , axis = 0 ):
34183409 """
0 commit comments