@@ -3294,7 +3294,7 @@ def _iget_item_cache(self, item):
32943294 if ax .is_unique :
32953295 lower = self ._get_item_cache (ax [item ])
32963296 else :
3297- lower = self ._take (item , axis = self ._info_axis_number )
3297+ lower = self .take (item , axis = self ._info_axis_number )
32983298 return lower
32993299
33003300 def _box_item_values (self , key , values ):
@@ -3522,52 +3522,6 @@ def __delitem__(self, key):
35223522 except KeyError :
35233523 pass
35243524
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-
35713525 def take (self , indices , axis = 0 , is_copy = True , ** kwargs ):
35723526 """
35733527 Return the elements in the given *positional* indices along an axis.
@@ -3644,7 +3598,20 @@ class max_speed
36443598 3 lion mammal 80.5
36453599 """
36463600 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
36483615
36493616 def xs (self , key , axis = 0 , level = None , drop_level = True ):
36503617 """
@@ -3773,9 +3740,9 @@ class animal locomotion
37733740 if isinstance (loc , np .ndarray ):
37743741 if loc .dtype == np .bool_ :
37753742 inds , = loc .nonzero ()
3776- return self ._take (inds , axis = axis )
3743+ return self .take (inds , axis = axis )
37773744 else :
3778- return self ._take (loc , axis = axis )
3745+ return self .take (loc , axis = axis )
37793746
37803747 if not is_scalar (loc ):
37813748 new_index = self .index [loc ]
@@ -8091,7 +8058,7 @@ def at_time(self, time, asof=False, axis=None):
80918058 except AttributeError :
80928059 raise TypeError ("Index must be DatetimeIndex" )
80938060
8094- return self ._take (indexer , axis = axis )
8061+ return self .take (indexer , axis = axis )
80958062
80968063 def between_time (
80978064 self , start_time , end_time , include_start = True , include_end = True , axis = None
@@ -8168,7 +8135,7 @@ def between_time(
81688135 except AttributeError :
81698136 raise TypeError ("Index must be DatetimeIndex" )
81708137
8171- return self ._take (indexer , axis = axis )
8138+ return self .take (indexer , axis = axis )
81728139
81738140 def resample (
81748141 self ,
0 commit comments