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.

Calls str.find element-wise.

For each element, return the lowest index in the string where substring sub is found, such that sub is contained in the range [start, end].

Parameters:
aarray_like of str or unicode
substr or unicode
start, endint, optional

Optional arguments start and end are interpreted as in slice notation.

Returns:
outndarray or int

Output array of ints. Returns -1 if sub is not found.

See also

str.find

Examples

>>> a = np.array(["NumPy is a Python library"])
>>> np.char.find(a, "Python", start=0, end=None)
array([11])