For each element in `a`, return a copy with the leading 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 t
(a, chars=None)
| 941 | |
| 942 | @set_module("numpy.strings") |
| 943 | def lstrip(a, chars=None): |
| 944 | """ |
| 945 | For each element in `a`, return a copy with the leading characters |
| 946 | removed. |
| 947 | |
| 948 | Parameters |
| 949 | ---------- |
| 950 | a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype |
| 951 | chars : scalar with the same dtype as ``a``, optional |
| 952 | The ``chars`` argument is a string specifying the set of |
| 953 | characters to be removed. If ``None``, the ``chars`` |
| 954 | argument defaults to removing whitespace. The ``chars`` argument |
| 955 | is not a prefix or suffix; rather, all combinations of its |
| 956 | values are stripped. |
| 957 | |
| 958 | Returns |
| 959 | ------- |
| 960 | out : ndarray |
| 961 | Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype, |
| 962 | depending on input types |
| 963 | |
| 964 | See Also |
| 965 | -------- |
| 966 | str.lstrip |
| 967 | |
| 968 | Examples |
| 969 | -------- |
| 970 | >>> import numpy as np |
| 971 | >>> c = np.array(['aAaAaA', ' aA ', 'abBABba']) |
| 972 | >>> c |
| 973 | array(['aAaAaA', ' aA ', 'abBABba'], dtype='<U7') |
| 974 | # The 'a' variable is unstripped from c[1] because of leading whitespace. |
| 975 | >>> np.strings.lstrip(c, 'a') |
| 976 | array(['AaAaA', ' aA ', 'bBABba'], dtype='<U7') |
| 977 | >>> np.strings.lstrip(c, 'A') # leaves c unchanged |
| 978 | array(['aAaAaA', ' aA ', 'abBABba'], dtype='<U7') |
| 979 | >>> (np.strings.lstrip(c, ' ') == np.strings.lstrip(c, '')).all() |
| 980 | np.False_ |
| 981 | >>> (np.strings.lstrip(c, ' ') == np.strings.lstrip(c)).all() |
| 982 | np.True_ |
| 983 | |
| 984 | """ |
| 985 | if chars is None: |
| 986 | return _lstrip_whitespace(a) |
| 987 | return _lstrip_chars(a, chars) |
| 988 | |
| 989 | |
| 990 | @set_module("numpy.strings") |
no outgoing calls
no test coverage detected
searching dependent graphs…