numpy.char.rstrip#
- char.rstrip(a, chars=None)[source]#
For each element in a, return a copy with the trailing 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 types
See also
Examples
>>> import numpy as np >>> c = np.array(['aAaAaA', 'abBABba']) >>> c array(['aAaAaA', 'abBABba'], dtype='<U7') >>> np.strings.rstrip(c, 'a') array(['aAaAaA', 'abBABb'], dtype='<U7') >>> np.strings.rstrip(c, 'A') array(['aAaAa', 'abBABba'], dtype='<U7')