numpy.strings.index#

strings.index(a,sub,start=0,end=None)[source]#

Likefind, but raisesValueError when the substring is not found.

Parameters:
aarray-like, withStringDType,bytes_, orstr_ dtype
subarray-like, withStringDType,bytes_, orstr_ dtype
start, endarray_like, with any integer dtype, optional
Returns:
outndarray

Output array of ints.

See also

find,str.index

Examples

>>>importnumpyasnp>>>a=np.array(["Computer Science"])>>>np.strings.index(a,"Science",start=0,end=None)array([9])
On this page