MCPcopy Index your code
hub / github.com/pydata/xarray / partition

Method partition

xarray/core/accessor_str.py:2408–2444  ·  view source on GitHub ↗

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 = " ",
    )

Source from the content-addressed store, hash-verified

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,

Callers 5

test_partition_commaFunction · 0.80
test_partition_emptyFunction · 0.80
test_splitters_broadcastFunction · 0.80
test_splitters_empty_strFunction · 0.80

Calls 1

_partitionerMethod · 0.95

Tested by 5

test_partition_commaFunction · 0.64
test_partition_emptyFunction · 0.64
test_splitters_broadcastFunction · 0.64
test_splitters_empty_strFunction · 0.64