[ Web Proxy ]
URL:
Viewing: https://numpy.org/doc/stable/reference/generated/../c-api/../generated/numpy.strings.rstrip.html [Back]  [Original]

numpy.strings.rstrip — NumPy v2.5 Manual
Back to top
Search the docs ...:

numpy.strings.rstrip#

strings.rstrip(a, chars=None)[source]#

For each element in a, return a copy with the trailing characters removed.

Parameters:
aarray-like, with StringDType, bytes_, or str_ dtype
charsscalar with the same dtype as a, optional

The 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.

Returns:
outndarray

Output array of StringDType, bytes_ or str_ dtype, depending on input types

See also

str.rstrip

Examples

Try it in your browser!
>>> 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')

Web Proxy Viewer  |  New URL  |  Original Page