Returns a boolean array which is `True` where the string element in ``a`` starts with ``prefix``, otherwise `False`. Parameters ---------- a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype prefix : array-like, with ``StringDType``, ``bytes_``, or ``str_``
(a, prefix, start=0, end=None)
| 448 | |
| 449 | @set_module("numpy.strings") |
| 450 | def startswith(a, prefix, start=0, end=None): |
| 451 | """ |
| 452 | Returns a boolean array which is `True` where the string element |
| 453 | in ``a`` starts with ``prefix``, otherwise `False`. |
| 454 | |
| 455 | Parameters |
| 456 | ---------- |
| 457 | a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype |
| 458 | |
| 459 | prefix : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype |
| 460 | |
| 461 | start, end : array_like, with any integer dtype |
| 462 | With ``start``, test beginning at that position. With ``end``, |
| 463 | stop comparing at that position. |
| 464 | |
| 465 | Returns |
| 466 | ------- |
| 467 | out : ndarray |
| 468 | Output array of bools |
| 469 | |
| 470 | See Also |
| 471 | -------- |
| 472 | str.startswith |
| 473 | |
| 474 | Examples |
| 475 | -------- |
| 476 | >>> import numpy as np |
| 477 | >>> s = np.array(['foo', 'bar']) |
| 478 | >>> s |
| 479 | array(['foo', 'bar'], dtype='<U3') |
| 480 | >>> np.strings.startswith(s, 'fo') |
| 481 | array([True, False]) |
| 482 | >>> np.strings.startswith(s, 'o', start=1, end=2) |
| 483 | array([True, False]) |
| 484 | |
| 485 | """ |
| 486 | end = end if end is not None else MAX |
| 487 | return _startswith_ufunc(a, prefix, start, end) |
| 488 | |
| 489 | |
| 490 | @set_module("numpy.strings") |
no outgoing calls
no test coverage detected
searching dependent graphs…