@@ -3294,7 +3294,7 @@ def _iget_item_cache(self, item):
3294
3294
if ax .is_unique :
3295
3295
lower = self ._get_item_cache (ax [item ])
3296
3296
else :
3297
- lower = self ._take (item , axis = self ._info_axis_number )
3297
+ lower = self .take (item , axis = self ._info_axis_number )
3298
3298
return lower
3299
3299
3300
3300
def _box_item_values (self , key , values ):
@@ -3522,52 +3522,6 @@ def __delitem__(self, key):
3522
3522
except KeyError :
3523
3523
pass
3524
3524
3525
- def _take (self , indices , axis = 0 , is_copy = True ):
3526
- """
3527
- Return the elements in the given *positional* indices along an axis.
3528
-
3529
- This means that we are not indexing according to actual values in
3530
- the index attribute of the object. We are indexing according to the
3531
- actual position of the element in the object.
3532
-
3533
- This is the internal version of ``.take()`` and will contain a wider
3534
- selection of parameters useful for internal use but not as suitable
3535
- for public usage.
3536
-
3537
- Parameters
3538
- ----------
3539
- indices : array-like
3540
- An array of ints indicating which positions to take.
3541
- axis : int, default 0
3542
- The axis on which to select elements. "0" means that we are
3543
- selecting rows, "1" means that we are selecting columns, etc.
3544
- is_copy : bool, default True
3545
- Whether to return a copy of the original object or not.
3546
-
3547
- Returns
3548
- -------
3549
- taken : same type as caller
3550
- An array-like containing the elements taken from the object.
3551
-
3552
- See Also
3553
- --------
3554
- numpy.ndarray.take
3555
- numpy.take
3556
- """
3557
- self ._consolidate_inplace ()
3558
-
3559
- new_data = self ._data .take (
3560
- indices , axis = self ._get_block_manager_axis (axis ), verify = True
3561
- )
3562
- result = self ._constructor (new_data ).__finalize__ (self )
3563
-
3564
- # Maybe set copy if we didn't actually change the index.
3565
- if is_copy :
3566
- if not result ._get_axis (axis ).equals (self ._get_axis (axis )):
3567
- result ._set_is_copy (self )
3568
-
3569
- return result
3570
-
3571
3525
def take (self , indices , axis = 0 , is_copy = True , ** kwargs ):
3572
3526
"""
3573
3527
Return the elements in the given *positional* indices along an axis.
@@ -3644,7 +3598,20 @@ class max_speed
3644
3598
3 lion mammal 80.5
3645
3599
"""
3646
3600
nv .validate_take (tuple (), kwargs )
3647
- return self ._take (indices , axis = axis , is_copy = is_copy )
3601
+
3602
+ self ._consolidate_inplace ()
3603
+
3604
+ new_data = self ._data .take (
3605
+ indices , axis = self ._get_block_manager_axis (axis ), verify = True
3606
+ )
3607
+ result = self ._constructor (new_data ).__finalize__ (self )
3608
+
3609
+ # Maybe set copy if we didn't actually change the index.
3610
+ if is_copy :
3611
+ if not result ._get_axis (axis ).equals (self ._get_axis (axis )):
3612
+ result ._set_is_copy (self )
3613
+
3614
+ return result
3648
3615
3649
3616
def xs (self , key , axis = 0 , level = None , drop_level = True ):
3650
3617
"""
@@ -3773,9 +3740,9 @@ class animal locomotion
3773
3740
if isinstance (loc , np .ndarray ):
3774
3741
if loc .dtype == np .bool_ :
3775
3742
inds , = loc .nonzero ()
3776
- return self ._take (inds , axis = axis )
3743
+ return self .take (inds , axis = axis )
3777
3744
else :
3778
- return self ._take (loc , axis = axis )
3745
+ return self .take (loc , axis = axis )
3779
3746
3780
3747
if not is_scalar (loc ):
3781
3748
new_index = self .index [loc ]
@@ -8091,7 +8058,7 @@ def at_time(self, time, asof=False, axis=None):
8091
8058
except AttributeError :
8092
8059
raise TypeError ("Index must be DatetimeIndex" )
8093
8060
8094
- return self ._take (indexer , axis = axis )
8061
+ return self .take (indexer , axis = axis )
8095
8062
8096
8063
def between_time (
8097
8064
self , start_time , end_time , include_start = True , include_end = True , axis = None
@@ -8168,7 +8135,7 @@ def between_time(
8168
8135
except AttributeError :
8169
8136
raise TypeError ("Index must be DatetimeIndex" )
8170
8137
8171
- return self ._take (indexer , axis = axis )
8138
+ return self .take (indexer , axis = axis )
8172
8139
8173
8140
def resample (
8174
8141
self ,
0 commit comments