MCPcopy
hub / github.com/pandas-dev/pandas / reindex_indexer

Method reindex_indexer

pandas/core/internals/managers.py:813–898  ·  view source on GitHub ↗

Parameters ---------- new_axis : Index indexer : ndarray[intp] or None axis : int fill_value : object, default None allow_dups : bool, default False only_slice : bool, default False Whether to take views, not copies, along

(
        self,
        new_axis: Index,
        indexer: npt.NDArray[np.intp] | None,
        axis: AxisInt,
        fill_value=None,
        allow_dups: bool = False,
        only_slice: bool = False,
        *,
        use_na_proxy: bool = False,
    )

Source from the content-addressed store, hash-verified

811 )
812
813 def reindex_indexer(
814 self,
815 new_axis: Index,
816 indexer: npt.NDArray[np.intp] | None,
817 axis: AxisInt,
818 fill_value=None,
819 allow_dups: bool = False,
820 only_slice: bool = False,
821 *,
822 use_na_proxy: bool = False,
823 ) -> Self:
824 """
825 Parameters
826 ----------
827 new_axis : Index
828 indexer : ndarray[intp] or None
829 axis : int
830 fill_value : object, default None
831 allow_dups : bool, default False
832 only_slice : bool, default False
833 Whether to take views, not copies, along columns.
834 use_na_proxy : bool, default False
835 Whether to use an np.void ndarray for newly introduced columns.
836
837 pandas-indexer with -1's only.
838 """
839 if indexer is None:
840 if new_axis is self.axes[axis]:
841 # TODO(CoW) need to handle CoW?
842 return self
843
844 result = self.copy(deep=False)
845 result.axes = list(self.axes)
846 result.axes[axis] = new_axis
847 return result
848
849 # Should be intp, but in some cases we get int64 on 32bit builds
850 assert isinstance(indexer, np.ndarray)
851
852 # some axes don't allow reindexing with dups
853 if not allow_dups:
854 self.axes[axis]._validate_can_reindex(indexer)
855
856 if axis >= self.ndim:
857 raise IndexError("Requested axis not found in manager")
858
859 if axis == 0:
860 new_blocks = list(
861 self._slice_take_blocks_ax0(
862 indexer,
863 fill_value=fill_value,
864 only_slice=only_slice,
865 use_na_proxy=use_na_proxy,
866 )
867 )
868 else:
869 new_blocks = []
870 for blk in self.blocks:

Callers 11

reindex_axisMethod · 0.95
takeMethod · 0.95
_take_new_indexFunction · 0.80
shiftMethod · 0.80
_drop_axisMethod · 0.80
_align_seriesMethod · 0.80
_reindex_and_concatMethod · 0.80

Calls 9

copyMethod · 0.95
NumpyBlockClass · 0.90
_validate_can_reindexMethod · 0.80
take_ndMethod · 0.80
emptyMethod · 0.45
appendMethod · 0.45
viewMethod · 0.45
from_blocksMethod · 0.45

Tested by 1