@@ -3789,7 +3789,7 @@ def _reorder_indexer(
3789
3789
return indexer [ind ]
3790
3790
3791
3791
@overload
3792
- def searchsorted (
3792
+ def searchsorted ( # type: ignore[overload-overlap]
3793
3793
self ,
3794
3794
value : ScalarLike_co ,
3795
3795
side : Literal ["left" , "right" ] = ...,
@@ -3809,7 +3809,7 @@ def searchsorted(
3809
3809
value : NumpyValueArrayLike | ExtensionArray ,
3810
3810
side : Literal ["left" , "right" ] = "left" ,
3811
3811
sorter : npt .NDArray [np .intp ] | None = None ,
3812
- ) -> np .intp | npt . NDArray [ np .intp ] :
3812
+ ) -> npt . NDArray [ np .intp ] | np .intp :
3813
3813
"""
3814
3814
Find the indices where elements should be inserted to maintain order.
3815
3815
@@ -3826,8 +3826,9 @@ def searchsorted(
3826
3826
3827
3827
Returns
3828
3828
-------
3829
- npt.NDArray[np.intp]
3830
- Array of insertion points.
3829
+ npt.NDArray[np.intp] or np.intp
3830
+ The index or indices where the value(s) should be inserted to
3831
+ maintain order.
3831
3832
3832
3833
See Also
3833
3834
--------
@@ -3837,7 +3838,7 @@ def searchsorted(
3837
3838
--------
3838
3839
>>> mi = pd.MultiIndex.from_arrays([["a", "b", "c"], ["x", "y", "z"]])
3839
3840
>>> mi.searchsorted(("b", "y"))
3840
- 1
3841
+ array([1])
3841
3842
"""
3842
3843
3843
3844
if not value :
@@ -3876,7 +3877,8 @@ def searchsorted(
3876
3877
sorter = sorter ,
3877
3878
)
3878
3879
result .append (np .intp (pos [0 ]))
3879
-
3880
+ if len (result ) == 1 :
3881
+ return result [0 ]
3880
3882
return np .array (result , dtype = np .intp )
3881
3883
3882
3884
def truncate (self , before = None , after = None ) -> MultiIndex :
0 commit comments