numpy.char.index#
- char.index(a, sub, start=0, end=None)[source]#
Like
find
, but raisesValueError
when the substring is not found.- Parameters:
- aarray-like, with
StringDType
,bytes_
, orstr_
dtype - subarray-like, with
StringDType
,bytes_
, orstr_
dtype - start, endarray_like, with any integer dtype, optional
- aarray-like, with
- Returns:
- outndarray
Output array of ints.
Examples
>>> import numpy as np >>> a = np.array(["Computer Science"]) >>> np.strings.index(a, "Science", start=0, end=None) array([9])