bundles / numpy 2.5.0.dev0+git20251130.2de293a / numpy / strings / slice
function
numpy.strings:slice
source: build-install/usr/lib/python3.14/site-packages/numpy/_core/strings.py :1729
Signature
def slice ( a , start = None , stop = <no value> , step = None , / ) Summary
Slice the strings in a by slices specified by start, stop, step. Like in the regular Python slice object, if only start is specified then it is interpreted as the stop.
Parameters
a: array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtypeInput array
start: None, an integer or an array of integersThe start of the slice, broadcasted to
a's shapestop: None, an integer or an array of integersThe end of the slice, broadcasted to
a's shapestep: None, an integer or an array of integersThe step for the slice, broadcasted to
a's shape
Returns
out: ndarrayOutput array of
StringDType,bytes_orstr_dtype, depending on input type
Examples
import numpy as np a = np.array(['hello', 'world']) np.strings.slice(a, 2)✓
np.strings.slice(a, 2, None)
✓np.strings.slice(a, 1, 5, 2)
✓np.strings.slice(a, np.array([1, 2]), np.array([4, 5]))
✓b = np.array(['hello world', 'γεια σου κόσμε', '你好世界', '👋 🌍'], dtype=np.dtypes.StringDType()) np.strings.slice(b, -2)✓
np.strings.slice(b, -2, None)
✓np.strings.slice(b, [3, -10, 2, -3], [-1, -2, -1, 3])
✓np.strings.slice(b, None, None, -1)
✓Aliases
-
numpy.strings.slice