@@ -3390,15 +3390,6 @@ def sortlevel(self, level=0, axis=0, ascending=True, inplace=False,
3390
3390
return self .sort_index (level = level , axis = axis , ascending = ascending ,
3391
3391
inplace = inplace , sort_remaining = sort_remaining )
3392
3392
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
-
3402
3393
def nlargest (self , n , columns , keep = 'first' ):
3403
3394
"""Get the rows of a DataFrame sorted by the `n` largest
3404
3395
values of `columns`.
@@ -3431,7 +3422,7 @@ def nlargest(self, n, columns, keep='first'):
3431
3422
1 10 b 2
3432
3423
2 8 d NaN
3433
3424
"""
3434
- return self . _nsorted ( columns , n , 'nlargest' , keep )
3425
+ return algos . select_n_frame ( self , columns , n , 'nlargest' , keep )
3435
3426
3436
3427
def nsmallest (self , n , columns , keep = 'first' ):
3437
3428
"""Get the rows of a DataFrame sorted by the `n` smallest
@@ -3465,7 +3456,7 @@ def nsmallest(self, n, columns, keep='first'):
3465
3456
0 1 a 1
3466
3457
2 8 d NaN
3467
3458
"""
3468
- return self . _nsorted ( columns , n , 'nsmallest' , keep )
3459
+ return algos . select_n_frame ( self , columns , n , 'nsmallest' , keep )
3469
3460
3470
3461
def swaplevel (self , i = - 2 , j = - 1 , axis = 0 ):
3471
3462
"""
0 commit comments