numpy.char.lstrip
- char.lstrip(a, chars=None)[source]
-
For each element in
a, return a copy with the leading characters removed.- Parameters:
-
-
aarray-like, with
StringDType,bytes_, orstr_dtype -
charsscalar with the same dtype as
a, optional -
The
charsargument is a string specifying the set of characters to be removed. IfNone, thecharsargument defaults to removing whitespace. Thecharsargument is not a prefix or suffix; rather, all combinations of its values are stripped.
-
aarray-like, with
- Returns:
-
- outndarray
-
Output array of
StringDType,bytes_orstr_dtype, depending on input type
See also
Examples
>>> c = np.array(['aAaAaA', ' aA ', 'abBABba']) >>> c array(['aAaAaA', ' aA ', 'abBABba'], dtype='<U7') # The 'a' variable is unstripped from c[1] because of leading whitespace. >>> np.strings.lstrip(c, 'a') array(['AaAaA', ' aA ', 'bBABba'], dtype='<U7') >>> np.strings.lstrip(c, 'A') # leaves c unchanged array(['aAaAaA', ' aA ', 'abBABba'], dtype='<U7') >>> (np.strings.lstrip(c, ' ') == np.strings.lstrip(c, '')).all() np.False_ >>> (np.strings.lstrip(c, ' ') == np.strings.lstrip(c)).all() np.True_
© 2005–2024 NumPy Developers
Licensed under the 3-clause BSD License.
https://numpy.org/doc/2.0/reference/generated/numpy.char.lstrip.html