numpy.char.find
- char.find(a, sub, start=0, end=None)[source]
-
For each element, return the lowest index in the string where substring
sub
is found, such thatsub
is contained in the range [start
,end
).- Parameters:
-
-
aarray_like, with
StringDType
,bytes_
orstr_
dtype -
subarray_like, with
np.bytes_
ornp.str_
dtype -
The substring to search for.
- start, endarray_like, with any integer dtype
-
The range to look in, interpreted as in slice notation.
-
aarray_like, with
- Returns:
-
- yndarray
-
Output array of ints
See also
Examples
>>> a = np.array(["NumPy is a Python library"]) >>> np.strings.find(a, "Python") array([11])
© 2005–2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.0/reference/generated/numpy.char.find.html