bundles / numpy latest / numpy / strings / index
function
numpy.strings:index
source: build-install/usr/lib/python3.14/site-packages/numpy/_core/strings.py:336
Signature
def index(a, sub, start = 0, end = None)Summary
Like find, but raises ValueError when the substring is not found.
Parameters
a: array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtypesub: array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtypestart, end: array_like, with any integer dtype, optional
Returns
out: ndarrayOutput array of ints.
Examples
import numpy as np a = np.array(["Computer Science"]) np.strings.index(a, "Science", start=0, end=None)✓
array([9])
See also
- find
- str.index
Aliases
numpy.char.index