Skip to content

Commit 9a8a2e1

Browse files
committed
DOC: add char.rfind example
[skip actions][skip azp][skip cirrus]
1 parent 98b5aa5 commit 9a8a2e1

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

numpy/_core/strings.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,9 @@ def mod(a, values):
199199
200200
Examples
201201
--------
202-
>>> np.char.mod("%.3f", [1, 2, 3])
202+
>>> np.strings.mod("%.3f", [1, 2, 3])
203203
array(['1.000', '2.000', '3.000'], dtype='<U5')
204-
>>> np.char.mod("0x%02x", [8, 9, 10, 11])
204+
>>> np.strings.mod("0x%02x", [8, 9, 10, 11])
205205
array(['0x08', '0x09', '0x0a', '0x0b'], dtype='<U4')
206206
207207
"""
@@ -270,6 +270,20 @@ def rfind(a, sub, start=0, end=None):
270270
--------
271271
str.rfind
272272
273+
Examples
274+
--------
275+
276+
While `string.find` returns the lowest index:
277+
278+
>>> a = np.array(["very repetitive very repetitive very"])
279+
>>> np.strings.find(a, "very")
280+
array([0])
281+
282+
`string.rfind` returns the highes index:
283+
284+
>>> np.strings.rfind(a, "very")
285+
array([32])
286+
273287
"""
274288
end = end if end is not None else MAX
275289
return _rfind_ufunc(a, sub, start, end)

0 commit comments

Comments
 (0)