Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Numpy string operations | rpartition() function

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

In the numpy.core.defchararray.rpartition() function,  each element in arr, split the element as the last occurrence of sep, and return 3 strings containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, return 3 strings containing the string itself, followed by two empty strings.

Syntax : numpy.core.defchararray.rpartition(arr, sep)

Parameters :

arr : [array_like, {str, unicode}]  Given Input array.

sep : [str or unicode] Right-most separator to split each element in array.

Return : [ndarray] Return the output array of str or unicode, depending on input type

Code #1 :  

Python3




# Python program explaining 
# numpy.char.rpartition() function 
  
# importing numpy as geek  
import numpy as geek 
  
arr = "GeeksforGeeks - A computer science portal for geeks"
sep = 'None'
  
gfg = geek.char.rpartition(arr, sep)
    
print (gfg)


Output :  

[” ” ‘GeeksforGeeks – A computer science portal for geeks’]

Code #2 :  

Python3




# Python program explaining 
# numpy.char.rpartition() function 
  
# importing numpy as geek  
import numpy as geek 
  
arr = "GeeksforGeeks - A computer science portal for geeks"
sep = 'science'
  
gfg = geek.char.rpartition(arr, sep)
    
print (gfg)


Output : 

[‘GeeksforGeeks – A computer ‘ ‘science’ ‘ portal for geeks’]

My Personal Notes arrow_drop_up
Last Updated : 29 Aug, 2020
Like Article
Save Article
Similar Reads