(
self, other: Index, how: JoinHow = "left"
)
| 4848 | return join_index, left_indexer, right_indexer |
| 4849 | |
| 4850 | def _join_monotonic( |
| 4851 | self, other: Index, how: JoinHow = "left" |
| 4852 | ) -> tuple[Index, npt.NDArray[np.intp] | None, npt.NDArray[np.intp] | None]: |
| 4853 | # We only get here with (caller is responsible for ensuring): |
| 4854 | # 1) matching dtypes |
| 4855 | # 2) both monotonic increasing |
| 4856 | # 3) other.is_unique or self.is_unique |
| 4857 | assert other.dtype == self.dtype |
| 4858 | assert self._can_use_libjoin and other._can_use_libjoin |
| 4859 | |
| 4860 | if self.equals(other): |
| 4861 | # This is a convenient place for this check, but its correctness |
| 4862 | # does not depend on monotonicity, so it could go earlier |
| 4863 | # in the calling method. |
| 4864 | ret_index = other if how == "right" else self |
| 4865 | return ret_index, None, None |
| 4866 | |
| 4867 | ridx: npt.NDArray[np.intp] | None |
| 4868 | lidx: npt.NDArray[np.intp] | None |
| 4869 | |
| 4870 | if how == "left": |
| 4871 | if other.is_unique: |
| 4872 | # We can perform much better than the general case |
| 4873 | join_index = self |
| 4874 | lidx = None |
| 4875 | ridx = self._left_indexer_unique(other) |
| 4876 | else: |
| 4877 | join_array, lidx, ridx = self._left_indexer(other) |
| 4878 | join_index, lidx, ridx = self._wrap_join_result( |
| 4879 | join_array, other, lidx, ridx, how |
| 4880 | ) |
| 4881 | elif how == "right": |
| 4882 | if self.is_unique: |
| 4883 | # We can perform much better than the general case |
| 4884 | join_index = other |
| 4885 | lidx = other._left_indexer_unique(self) |
| 4886 | ridx = None |
| 4887 | else: |
| 4888 | join_array, ridx, lidx = other._left_indexer(self) |
| 4889 | join_index, lidx, ridx = self._wrap_join_result( |
| 4890 | join_array, other, lidx, ridx, how |
| 4891 | ) |
| 4892 | elif how == "inner": |
| 4893 | join_array, lidx, ridx = self._inner_indexer(other) |
| 4894 | join_index, lidx, ridx = self._wrap_join_result( |
| 4895 | join_array, other, lidx, ridx, how |
| 4896 | ) |
| 4897 | elif how == "outer": |
| 4898 | join_array, lidx, ridx = self._outer_indexer(other) |
| 4899 | join_index, lidx, ridx = self._wrap_join_result( |
| 4900 | join_array, other, lidx, ridx, how |
| 4901 | ) |
| 4902 | |
| 4903 | lidx = None if lidx is None else ensure_platform_int(lidx) |
| 4904 | ridx = None if ridx is None else ensure_platform_int(ridx) |
| 4905 | return join_index, lidx, ridx |
| 4906 | |
| 4907 | def _wrap_join_result( |
no test coverage detected