MCPcopy
hub / github.com/pydata/xarray / slice

Method slice

xarray/core/accessor_str.py:356–385  ·  view source on GitHub ↗

Slice substrings from each string in the array. If `start`, `stop`, or 'step` is array-like, they are broadcast against the array and applied elementwise. Parameters ---------- start : int or array-like of int, optional Start position fo

(
        self,
        start: int | Any | None = None,
        stop: int | Any | None = None,
        step: int | Any | None = None,
    )

Source from the content-addressed store, hash-verified

354 return self._apply(func=f, func_args=(i,))
355
356 def slice(
357 self,
358 start: int | Any | None = None,
359 stop: int | Any | None = None,
360 step: int | Any | None = None,
361 ) -> T_DataArray:
362 """
363 Slice substrings from each string in the array.
364
365 If `start`, `stop`, or 'step` is array-like, they are broadcast
366 against the array and applied elementwise.
367
368 Parameters
369 ----------
370 start : int or array-like of int, optional
371 Start position for slice operation.
372 If array-like, it is broadcast.
373 stop : int or array-like of int, optional
374 Stop position for slice operation.
375 If array-like, it is broadcast.
376 step : int or array-like of int, optional
377 Step size for slice operation.
378 If array-like, it is broadcast.
379
380 Returns
381 -------
382 sliced strings : same type as values
383 """
384 f = lambda x, istart, istop, istep: x[slice(istart, istop, istep)]
385 return self._apply(func=f, func_args=(start, stop, step))
386
387 def slice_replace(
388 self,

Callers 4

__getitem__Method · 0.95
test_empty_str_methodsFunction · 0.45
test_sliceFunction · 0.45
test_slice_broadcastFunction · 0.45

Calls 1

_applyMethod · 0.95

Tested by 3

test_empty_str_methodsFunction · 0.36
test_sliceFunction · 0.36
test_slice_broadcastFunction · 0.36