You are viewing an older version (2.4.3). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy 2.4.3 / numpy / strings / strip

function

numpy.strings:strip

source: /numpy/_core/strings.py :1033

Signature

def   strip ( a chars = None )

Summary

For each element in a, return a copy with the leading and trailing characters removed.

Parameters

a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
chars : scalar with the same dtype as ``a``, optional

The chars argument is a string specifying the set of characters to be removed. If None, the chars argument defaults to removing whitespace. The chars argument is not a prefix or suffix; rather, all combinations of its values are stripped.

Returns

out : ndarray

Output array of StringDType, bytes_ or str_ dtype, depending on input types

Examples

import numpy as np
c = np.array(['aAaAaA', '  aA  ', 'abBABba'])
c
np.strings.strip(c)
np.strings.strip(c, 'a')
np.strings.strip(c, 'A')

See also

str.strip

Aliases

  • numpy.char.strip