bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / char / partition
function
numpy.char:partition
source: build-install/usr/lib/python3.14/site-packages/numpy/_core/defchararray.py :318
Signature
def partition ( a , sep ) Summary
Partition each element in a around sep.
Extended Summary
Calls str.partition element-wise.
For each element in a, split the element as the first 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.
Parameters
a: array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtypeInput array
sep: {str, unicode}Separator to split each string element in
a.
Returns
out: ndarrayOutput array of
StringDType,bytes_orstr_dtype, depending on input types. The output array will have an extra dimension with 3 elements per input element.
Examples
import numpy as np x = np.array(["Numpy is nice!"]) np.char.partition(x, " ")✓
See also
- str.partition
Aliases
-
numpy.char.partition