NumPy

Previous topic

numpy.char.rsplit

Next topic

numpy.char.split

This is documentation for an old release of NumPy (version 1.19). Read this page in the documentation of the latest stable release (version 2.2).

numpy.char.rstrip

numpy.char.rstrip(a, chars=None)

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

Calls str.rstrip element-wise.

Parameters
aarray-like of str or unicode
charsstr or unicode, optional

The chars argument is a string specifying the set of characters to be removed. If omitted or None, the chars argument defaults to removing whitespace. The chars argument is not a suffix; rather, all combinations of its values are stripped.

Returns
outndarray

Output array of str or unicode, depending on input type

See also

str.rstrip

Examples

>>>
>>> c = np.array(['aAaAaA', 'abBABba'], dtype='S7'); c
array(['aAaAaA', 'abBABba'],
    dtype='|S7')
>>> np.char.rstrip(c, b'a')
array(['aAaAaA', 'abBABb'],
    dtype='|S7')
>>> np.char.rstrip(c, b'A')
array(['aAaAa', 'abBABba'],
    dtype='|S7')