8000 DOC: Add examples to ``np.char`` by luxedo · Pull Request #26642 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

DOC: Add examples to np.char #26642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Oct 14, 2024
Prev Previous commit
Next Next commit
DOC: add char.rfind example
[skip actions][skip azp][skip cirrus]
  • Loading branch information
luxedo committed Jun 8, 2024
commit 9a8a2e1de0b1d07a087833fe0e671589902b4e9f
8000
18 changes: 16 additions & 2 deletions numpy/_core/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ def mod(a, values):

Examples
--------
>>> np.char.mod("%.3f", [1, 2, 3])
>>> np.strings.mod("%.3f", [1, 2, 3])
array(['1.000', '2.000', '3.000'], dtype='<U5')
>>> np.char.mod("0x%02x", [8, 9, 10, 11])
>>> np.strings.mod("0x%02x", [8, 9, 10, 11])
array(['0x08', '0x09', '0x0a', '0x0b'], dtype='<U4')

"""
Expand Down Expand Up @@ -270,6 +270,20 @@ def rfind(a, sub, start=0, end=None):
--------
str.rfind

Examples
--------

While `string.find` returns the lowest index:

>>> a = np.array(["very repetitive very repetitive very"])
>>> np.strings.find(a, "very")
array([0])

`string.rfind` returns the highes index:

>>> np.strings.rfind(a, "very")
array([32])

"""
end = end if end is not None else MAX
return _rfind_ufunc(a, sub, start, end)
Expand Down
0