numpy.strings.lstrip
- strings.lstrip(a, chars=None)
For each element in a, return a copy with the leading characters removed.
- Parameters:
- a : array-like, with
StringDType,bytes_, ordtype
- a : array-like, with
For each element in a, return a copy with the leading characters removed.
StringDType, bytes_, or dtypea, optionalThe 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.
Output array of StringDType, bytes_ or str_ dtype,
depending on input types
>>> import numpy as np
>>> 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_