Split the strings in the DataArray at the first occurrence of separator `sep`. This method splits the string at the first occurrence of `sep`, and returns 3 elements containing the part before the separator, the separator itself, and the part after the separator.
(
self,
dim: Hashable | None,
sep: str | bytes | Any = " ",
)
| 2406 | ) |
| 2407 | |
| 2408 | def partition( |
| 2409 | self, |
| 2410 | dim: Hashable | None, |
| 2411 | sep: str | bytes | Any = " ", |
| 2412 | ) -> T_DataArray: |
| 2413 | """ |
| 2414 | Split the strings in the DataArray at the first occurrence of separator `sep`. |
| 2415 | |
| 2416 | This method splits the string at the first occurrence of `sep`, |
| 2417 | and returns 3 elements containing the part before the separator, |
| 2418 | the separator itself, and the part after the separator. |
| 2419 | If the separator is not found, return 3 elements containing the string itself, |
| 2420 | followed by two empty strings. |
| 2421 | |
| 2422 | If `sep` is array-like, it is broadcast against the array and applied |
| 2423 | elementwise. |
| 2424 | |
| 2425 | Parameters |
| 2426 | ---------- |
| 2427 | dim : hashable or None |
| 2428 | Name for the dimension to place the 3 elements in. |
| 2429 | If `None`, place the results as list elements in an object DataArray. |
| 2430 | sep : str or bytes or array-like, default: " " |
| 2431 | String to split on. |
| 2432 | If array-like, it is broadcast. |
| 2433 | |
| 2434 | Returns |
| 2435 | ------- |
| 2436 | partitioned : same type as values or object array |
| 2437 | |
| 2438 | See Also |
| 2439 | -------- |
| 2440 | DataArray.str.rpartition |
| 2441 | str.partition |
| 2442 | pandas.Series.str.partition |
| 2443 | """ |
| 2444 | return self._partitioner(func=self._obj.dtype.type.partition, dim=dim, sep=sep) |
| 2445 | |
| 2446 | def rpartition( |
| 2447 | self, |