numpy.strings.rpartition#

strings.rpartition(a,sep)[source]#

Partition (split) each element around the right-most separator.

For each element ina, split the element at the lastoccurrence ofsep, and return a 3-tuple containing the partbefore the separator, the separator itself, and the part afterthe separator. If the separator is not found, the third item ofthe tuple will contain the whole string, and the first and secondones will be the empty string.

Parameters:
aarray-like, withStringDType,bytes_, orstr_ dtype

Input array

separray-like, withStringDType,bytes_, orstr_ dtype

Separator to split each string element ina.

Returns:
out3-tuple:
  • array withStringDType,bytes_ orstr_ dtype with thepart before the separator

  • array withStringDType,bytes_ orstr_ dtype with theseparator

  • array withStringDType,bytes_ orstr_ dtype with thepart after the separator

Examples

>>>importnumpyasnp>>>a=np.array(['aAaAaA','  aA  ','abBABba'])>>>np.strings.rpartition(a,'A')(array(['aAaAa', '  a', 'abB'], dtype='<U5'), array(['A', 'A', 'A'], dtype='<U1'), array(['', '  ', 'Bba'], dtype='<U3'))
On this page