-
numpy.core.defchararray.lstrip(a, chars=None)
[source] -
For each element in
a
, return a copy with the leading characters removed.Calls
str.lstrip
element-wise.Parameters: a : array-like, {str, unicode}
Input array.
chars : {str, unicode}, optional
The
chars
argument is a string specifying the set of characters to be removed. If omitted or None, thechars
argument defaults to removing whitespace. Thechars
argument is not a prefix; rather, all combinations of its values are stripped.Returns: out : ndarray, {str, unicode}
Output array of str or unicode, depending on input type
See also
Examples
1234>>> c
=
np.array([
'aAaAaA'
,
' aA '
,
'abBABba'
])
>>> c
array([
'aAaAaA'
,
' aA '
,
'abBABba'
],
dtype
=
'|S7'
)
The ?a? variable is unstripped from c[1] because whitespace leading.
123>>> np.char.lstrip(c,
'a'
)
array([
'AaAaA'
,
' aA '
,
'bBABba'
],
dtype
=
'|S7'
)
123456789>>> np.char.lstrip(c,
'A'
)
# leaves c unchanged
array([
'aAaAaA'
,
' aA '
,
'abBABba'
],
dtype
=
'|S7'
)
>>> (np.char.lstrip(c,
' '
)
=
=
np.char.lstrip(c, '')).
all
()
...
# XXX: is this a regression? this line now returns False
...
# np.char.lstrip(c,'') does not modify c at all.
True
>>> (np.char.lstrip(c,
' '
)
=
=
np.char.lstrip(c,
None
)).
all
()
True
numpy.core.defchararray.lstrip()

2025-01-10 15:47:30
Please login to continue.