bundles / numpy latest / numpy / strings / partition
_ArrayFunctionDispatcher
numpy.strings:partition
source: build-install/usr/lib/python3.14/site-packages/numpy/_core/strings.py :1536
Signature
def partition ( a , sep ) Summary
Partition each element in a around sep.
Extended Summary
For each element in a, split the element at the first occurrence of sep, and return a 3-tuple containing the part before the separator, the separator itself, and the part after the separator. If the separator is not found, the first item of the tuple will contain the whole string, and the second and third ones will be the empty string.
Parameters
a: array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtypeInput array
sep: array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtypeSeparator to split each string element in
a.
Returns
out: 3-tuple:array with
StringDType,bytes_orstr_dtype with the part before the separatorarray with
StringDType,bytes_orstr_dtype with the separatorarray with
StringDType,bytes_orstr_dtype with the part after the separator
Examples
import numpy as np x = np.array(["Numpy is nice!"])✓
np.strings.partition(x, " ")
✗See also
- str.partition
Aliases
-
numpy.strings.partition