MCPcopy Index your code
hub / github.com/numpy/numpy / index

Function index

numpy/_core/strings.py:337–367  ·  view source on GitHub ↗

Like `find`, but raises :exc:`ValueError` when the substring is not found. Parameters ---------- a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype sub : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype start, end : array_like, with any int

(a, sub, start=0, end=None)

Source from the content-addressed store, hash-verified

335
336@set_module("numpy.strings")
337def index(a, sub, start=0, end=None):
338 """
339 Like `find`, but raises :exc:`ValueError` when the substring is not found.
340
341 Parameters
342 ----------
343 a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
344
345 sub : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
346
347 start, end : array_like, with any integer dtype, optional
348
349 Returns
350 -------
351 out : ndarray
352 Output array of ints.
353
354 See Also
355 --------
356 find, str.index
357
358 Examples
359 --------
360 >>> import numpy as np
361 >>> a = np.array(["Computer Science"])
362 >>> np.strings.index(a, "Science", start=0, end=None)
363 array([9])
364
365 """
366 end = end if end is not None else MAX
367 return _index_ufunc(a, sub, start, end)
368
369
370@set_module("numpy.strings")

Callers 1

indexMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…