🍾 Xarray is now 10 years old! 🎉

xarray.core.accessor_str.StringAccessor.slice

xarray.core.accessor_str.StringAccessor.slice#

StringAccessor.slice(start=None, stop=None, step=None)[source]#

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 for slice operation. If array-like, it is broadcast.

  • stop (int or array-like of int, optional) – Stop position for slice operation. If array-like, it is broadcast.

  • step (int or array-like of int, optional) – Step size for slice operation. If array-like, it is broadcast.

Returns:

sliced strings (same type as values)