NumPy: rsplit() function
numpy.core.defchararray.rsplit() function
For each element in a given array the numpy.core.defchararray.rsplit() function returns a list of the words in the string, using sep as the delimiter string.
Calls str.rsplit element-wise.
Except for splitting from the right, rsplit behaves like split.
Version: 1.15.0
Syntax:
numpy.core.defchararray.rsplit(a, sep=None, maxsplit=None)
Parameter:
Name | Description | Required / Optional |
---|---|---|
a: array-like of str or unicode | Required | |
sep: str or unicode | If sep is not specified or None, any whitespace string is a separator. | Optional |
maxsplit: int | If maxsplit is given, at most maxsplit splits are done, the rightmost ones. | Optional |
Return value:
out : ndarray - Array of list objects
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.rsplit() function
>>> import numpy as np
>>> x = np.char.rsplit('w3resource', ':', maxsplit=None)
>>> x
array(list(['w3resource']), dtype=object)
Example-2: numpy.rsplit() function
>>> import numpy as np
>>> y = np.char.rsplit('hello world', ':', maxsplit=11)
>>> y
array(list(['hello world']), dtype=object)
Pictorial Presentation:
Python - NumPy Code Editor:
Previous:
rpartition()
Next:
rstrip()
- 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