In Python, the char.rpartition()
is used to split each element of an array of strings around the right-most separator.
char.rpartition(a, sep)
This function takes the following parameter values:
a
: This is the input array of strings or Unicode.sep
: This is the right-most separator to split each element in the given array.This function returns an array of strings or unicode, depending on the input type in the function.
import numpy as np# creating the input arraya = np.array(["Hi what are your doing?"])# creating seperator charactersep = "your"# implementing the char.rpartition() functionprint(np.char.rpartition(a, sep))
numpy
module.array()
function to create an array of strings myarray
.sep
that we use to partition the elements in the array.char.rpartition()
function on the variables myarray
and sep
. Next, we obtain and print the result.