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,
)
| 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: |