MCPcopy Index your code
hub / github.com/numpy/numpy / rpartition

Function rpartition

numpy/_core/defchararray.py:361–401  ·  view source on GitHub ↗

Partition (split) each element around the right-most separator. Calls :meth:`str.rpartition` element-wise. For each element in `a`, split the element as the last occurrence of `sep`, and return 3 strings containing the part before the separator, the separator itself, and the p

(a, sep)

Source from the content-addressed store, hash-verified

359
360@set_module("numpy.char")
361def rpartition(a, sep):
362 """
363 Partition (split) each element around the right-most separator.
364
365 Calls :meth:`str.rpartition` element-wise.
366
367 For each element in `a`, split the element as the last
368 occurrence of `sep`, and return 3 strings containing the part
369 before the separator, the separator itself, and the part after
370 the separator. If the separator is not found, return 3 strings
371 containing the string itself, followed by two empty strings.
372
373 Parameters
374 ----------
375 a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
376 Input array
377 sep : str or unicode
378 Right-most separator to split each element in array.
379
380 Returns
381 -------
382 out : ndarray
383 Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
384 depending on input types. The output array will have an extra
385 dimension with 3 elements per input element.
386
387 See Also
388 --------
389 str.rpartition
390
391 Examples
392 --------
393 >>> import numpy as np
394 >>> a = np.array(['aAaAaA', ' aA ', 'abBABba'])
395 >>> np.char.rpartition(a, 'A')
396 array([['aAaAa', 'A', ''],
397 [' a', 'A', ' '],
398 ['abB', 'A', 'Bba']], dtype='<U5')
399
400 """
401 return np.stack(strings_rpartition(a, sep), axis=-1)
402
403
404@set_module("numpy.char")

Callers 1

rpartitionMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…