MCPcopy Create free account
hub / github.com/numpy/numpy / lstrip

Function lstrip

numpy/core/defchararray.py:1143–1194  ·  view source on GitHub ↗

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

(a, chars=None)

Source from the content-addressed store, hash-verified

1141
1142@array_function_dispatch(_strip_dispatcher)
1143def lstrip(a, chars=None):
1144 """
1145 For each element in `a`, return a copy with the leading characters
1146 removed.
1147
1148 Calls `str.lstrip` element-wise.
1149
1150 Parameters
1151 ----------
1152 a : array-like, {str, unicode}
1153 Input array.
1154
1155 chars : {str, unicode}, optional
1156 The `chars` argument is a string specifying the set of
1157 characters to be removed. If omitted or None, the `chars`
1158 argument defaults to removing whitespace. The `chars` argument
1159 is not a prefix; rather, all combinations of its values are
1160 stripped.
1161
1162 Returns
1163 -------
1164 out : ndarray, {str, unicode}
1165 Output array of str or unicode, depending on input type
1166
1167 See Also
1168 --------
1169 str.lstrip
1170
1171 Examples
1172 --------
1173 >>> c = np.array(['aAaAaA', ' aA ', 'abBABba'])
1174 >>> c
1175 array(['aAaAaA', ' aA ', 'abBABba'], dtype='<U7')
1176
1177 The 'a' variable is unstripped from c[1] because whitespace leading.
1178
1179 >>> np.char.lstrip(c, 'a')
1180 array(['AaAaA', ' aA ', 'bBABba'], dtype='<U7')
1181
1182
1183 >>> np.char.lstrip(c, 'A') # leaves c unchanged
1184 array(['aAaAaA', ' aA ', 'abBABba'], dtype='<U7')
1185 >>> (np.char.lstrip(c, ' ') == np.char.lstrip(c, '')).all()
1186 ... # XXX: is this a regression? This used to return True
1187 ... # np.char.lstrip(c,'') does not modify c at all.
1188 False
1189 >>> (np.char.lstrip(c, ' ') == np.char.lstrip(c, None)).all()
1190 True
1191
1192 """
1193 a_arr = numpy.asarray(a)
1194 return _vec_string(a_arr, a_arr.dtype, 'lstrip', (chars,))
1195
1196
1197def _partition_dispatcher(a, sep):

Callers 1

lstripMethod · 0.85

Calls 1

_vec_stringFunction · 0.90

Tested by

no test coverage detected