Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

function
python
numpy
communitycreator

What is the numpy.char.rsplit() function in Python?

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

The numpy.char.rsplit() function in Python is used to return a list of words in the string of an array of strings using a sep as the delimiter string.

Syntax

char.rsplit(a, sep=None)

Parameter value

The numpy.char.rsplit() function takes the following parameter values:

  • a: This is the input array of strings or Unicode.
  • sep: This is the delimiter string or the separator. If this value is not specified, then a whitespace string is used as a separator.
  • maxsplit: This represents the maximum split that can be done. This parameter value is optional.

Return value

The numpy.char.rsplit() function returns an array of list objects.

Code example

import numpy as np
# creating an input array
a = np.array(['Artery', 'Material', 'Arterial'])
myarray= np.char.rsplit(a, sep ="er")
print(myarray)
Implementing the char.rsplit() function

Code explanation

  • Line 1: We import the numpy module.
  • Line 4: We create an array of strings, a, using the array() function.
  • Line 6: We implement the char.rsplit() function on the array a and assign the result to a variable called myarray.
  • Line 8: We print the array myarray.

RELATED TAGS

function
python
numpy
communitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring