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)
| 335 | |
| 336 | @set_module("numpy.strings") |
| 337 | def 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") |
no outgoing calls
no test coverage detected
searching dependent graphs…