Returns a boolean array which is `True` where the string element in `a` ends with `suffix`, otherwise `False`. Calls `str.endswith` element-wise. Parameters ---------- a : array_like of str or unicode suffix : str start, end : int, optional With optional
(a, suffix, start=0, end=None)
| 657 | |
| 658 | @array_function_dispatch(_endswith_dispatcher) |
| 659 | def endswith(a, suffix, start=0, end=None): |
| 660 | """ |
| 661 | Returns a boolean array which is `True` where the string element |
| 662 | in `a` ends with `suffix`, otherwise `False`. |
| 663 | |
| 664 | Calls `str.endswith` element-wise. |
| 665 | |
| 666 | Parameters |
| 667 | ---------- |
| 668 | a : array_like of str or unicode |
| 669 | |
| 670 | suffix : str |
| 671 | |
| 672 | start, end : int, optional |
| 673 | With optional `start`, test beginning at that position. With |
| 674 | optional `end`, stop comparing at that position. |
| 675 | |
| 676 | Returns |
| 677 | ------- |
| 678 | out : ndarray |
| 679 | Outputs an array of bools. |
| 680 | |
| 681 | See Also |
| 682 | -------- |
| 683 | str.endswith |
| 684 | |
| 685 | Examples |
| 686 | -------- |
| 687 | >>> s = np.array(['foo', 'bar']) |
| 688 | >>> s[0] = 'foo' |
| 689 | >>> s[1] = 'bar' |
| 690 | >>> s |
| 691 | array(['foo', 'bar'], dtype='<U3') |
| 692 | >>> np.char.endswith(s, 'ar') |
| 693 | array([False, True]) |
| 694 | >>> np.char.endswith(s, 'a', start=1, end=2) |
| 695 | array([False, True]) |
| 696 | |
| 697 | """ |
| 698 | return _vec_string( |
| 699 | a, bool_, 'endswith', [suffix, start] + _clean_args(end)) |
| 700 | |
| 701 | |
| 702 | def _expandtabs_dispatcher(a, tabsize=None): |
no test coverage detected