@@ -5679,29 +5679,49 @@ def asof_locs(
5679
5679
"""
5680
5680
Return the locations (indices) of labels in the index.
5681
5681
5682
- As in the ` asof` function , if the label (a particular entry in
5683
- `where`) is not in the index, the latest index label up to the
5682
+ As in the :meth:`pandas.Index. asof`, if the label (a particular entry in
5683
+ `` where` `) is not in the index, the latest index label up to the
5684
5684
passed label is chosen and its index returned.
5685
5685
5686
- If all of the labels in the index are later than a label in `where`,
5686
+ If all of the labels in the index are later than a label in `` where` `,
5687
5687
-1 is returned.
5688
5688
5689
- `mask` is used to ignore NA values in the index during calculation.
5689
+ `` mask`` is used to ignore ``NA`` values in the index during calculation.
5690
5690
5691
5691
Parameters
5692
5692
----------
5693
5693
where : Index
5694
5694
An Index consisting of an array of timestamps.
5695
5695
mask : np.ndarray[bool]
5696
5696
Array of booleans denoting where values in the original
5697
- data are not NA .
5697
+ data are not ``NA`` .
5698
5698
5699
5699
Returns
5700
5700
-------
5701
5701
np.ndarray[np.intp]
5702
- An array of locations (indices) of the labels from the Index
5703
- which correspond to the return values of the `asof` function
5704
- for every element in `where`.
5702
+ An array of locations (indices) of the labels from the index
5703
+ which correspond to the return values of :meth:`pandas.Index.asof`
5704
+ for every element in ``where``.
5705
+
5706
+ See Also
5707
+ --------
5708
+ Index.asof : Return the label from the index, or, if not present, the
5709
+ previous one.
5710
+
5711
+ Examples
5712
+ --------
5713
+ >>> idx = pd.date_range('2023-06-01', periods=3, freq='D')
5714
+ >>> where = pd.DatetimeIndex(['2023-05-30 00:12:00', '2023-06-01 00:00:00',
5715
+ ... '2023-06-02 23:59:59'])
5716
+ >>> mask = np.ones(3, dtype=bool)
5717
+ >>> idx.asof_locs(where, mask)
5718
+ array([-1, 0, 1])
5719
+
5720
+ We can use ``mask`` to ignore certain values in the index during calculation.
5721
+
5722
+ >>> mask[1] = False
5723
+ >>> idx.asof_locs(where, mask)
5724
+ array([-1, 0, 0])
5705
5725
"""
5706
5726
# error: No overload variant of "searchsorted" of "ndarray" matches argument
5707
5727
# types "Union[ExtensionArray, ndarray[Any, Any]]", "str"
@@ -6636,6 +6656,27 @@ def get_slice_bound(self, label, side: Literal["left", "right"]) -> int:
6636
6656
-------
6637
6657
int
6638
6658
Index of label.
6659
+
6660
+ See Also
6661
+ --------
6662
+ Index.get_loc : Get integer location, slice or boolean mask for requested
6663
+ label.
6664
+
6665
+ Examples
6666
+ --------
6667
+ >>> idx = pd.RangeIndex(5)
6668
+ >>> idx.get_slice_bound(3, 'left')
6669
+ 3
6670
+
6671
+ >>> idx.get_slice_bound(3, 'right')
6672
+ 4
6673
+
6674
+ If ``label`` is non-unique in the index, an error will be raised.
6675
+
6676
+ >>> idx_duplicate = pd.Index(['a', 'b', 'a', 'c', 'd'])
6677
+ >>> idx_duplicate.get_slice_bound('a', 'left')
6678
+ Traceback (most recent call last):
6679
+ KeyError: Cannot get left slice bound for non-unique label: 'a'
6639
6680
"""
6640
6681
6641
6682
if side not in ("left" , "right" ):
0 commit comments