Partition each element in a around sep.
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.
StringDType, bytes_, or str_ dtype
Input array
Separator to split each string element in a.
Output array of StringDType, bytes_ or str_ dtype, depending on input types. The output array will have an extra dimension with 3 elements per input element.
See also
>>> import numpy as np >>> x = np.array(["Numpy is nice!"]) >>> np.char.partition(x, " ") array([['Numpy', ' ', 'is nice!']], dtype='<U8')
© 2005–2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.4/reference/generated/numpy.char.partition.html