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