For each element, return the lowest index in the string where substring `sub` is found. Calls `str.find` element-wise. For each element, return the lowest index in the string where substring `sub` is found, such that `sub` is contained in the range [`start`, `end`]. P
(a, sub, start=0, end=None)
| 741 | |
| 742 | @array_function_dispatch(_count_dispatcher) |
| 743 | def find(a, sub, start=0, end=None): |
| 744 | """ |
| 745 | For each element, return the lowest index in the string where |
| 746 | substring `sub` is found. |
| 747 | |
| 748 | Calls `str.find` element-wise. |
| 749 | |
| 750 | For each element, return the lowest index in the string where |
| 751 | substring `sub` is found, such that `sub` is contained in the |
| 752 | range [`start`, `end`]. |
| 753 | |
| 754 | Parameters |
| 755 | ---------- |
| 756 | a : array_like of str or unicode |
| 757 | |
| 758 | sub : str or unicode |
| 759 | |
| 760 | start, end : int, optional |
| 761 | Optional arguments `start` and `end` are interpreted as in |
| 762 | slice notation. |
| 763 | |
| 764 | Returns |
| 765 | ------- |
| 766 | out : ndarray or int |
| 767 | Output array of ints. Returns -1 if `sub` is not found. |
| 768 | |
| 769 | See Also |
| 770 | -------- |
| 771 | str.find |
| 772 | |
| 773 | Examples |
| 774 | -------- |
| 775 | >>> a = np.array(["NumPy is a Python library"]) |
| 776 | >>> np.char.find(a, "Python", start=0, end=None) |
| 777 | array([11]) |
| 778 | |
| 779 | """ |
| 780 | return _vec_string( |
| 781 | a, int_, 'find', [sub, start] + _clean_args(end)) |
| 782 | |
| 783 | |
| 784 | @array_function_dispatch(_count_dispatcher) |
no test coverage detected