NumPy: rfind() function
numpy.core.defchararray.rfind() function
For each element in a given array numpy.core.defchararray.rfind() function returns the highest index in the string where substring sub is found, such that sub is contained within [start, end].
Calls str.rfind element-wise.
Syntax:
numpy.core.defchararray.rfind(a, sub, start=0, end=None)
Parameter:
Name | Description | Required / Optional |
---|---|---|
a: array_like of str or unicode | Input an array_like of string or unicode | Required |
sub: str or unicode | Input string or unicode | Required |
start, end: int | Optional arguments start and end are interpreted as in slice notation. | Optional |
Return value:
out : ndarray - Output array of ints. Return -1 on failure.
Note:
The 'chararray' class exists for backwards compatibility with Numarray, it is not recommended for new development. Starting from numpy 1.4, if one needs arrays of strings, it is recommended to use arrays of 'dtype' 'object_', 'string_' or 'unicode_', and use the free functions in the 'numpy.char' module for fast vectorized string operations.
Some methods will only be available if the corresponding string method is available in your version of Python.
The preferred alias for 'defchararray' is 'numpy.char'.
Example-1: numpy.rfind() function
>>> import numpy as np
>>> x = np.char.rfind('The Quick Brown Fox', 'Fox', start=0, end=None)
>>> x
array(16)
Pictorial Presentation:
Example-2: numpy.rfind() function
>>> import numpy as np
>>> y = np.char.rfind('the quick brown fox jumps over the lazy dog', 'over the lazy dog', start=0, end=None)
>>> y
array(26)
Pictorial Presentation:
Python - NumPy Code Editor:
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework