MCPcopy Index your code
hub / github.com/numpy/numpy / rstrip

Function rstrip

numpy/_core/strings.py:991–1030  ·  view source on GitHub ↗

For each element in `a`, return a copy with the trailing 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

(a, chars=None)

Source from the content-addressed store, hash-verified

989
990@set_module("numpy.strings")
991def rstrip(a, chars=None):
992 """
993 For each element in `a`, return a copy with the trailing characters
994 removed.
995
996 Parameters
997 ----------
998 a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
999 chars : scalar with the same dtype as ``a``, optional
1000 The ``chars`` argument is a string specifying the set of
1001 characters to be removed. If ``None``, the ``chars``
1002 argument defaults to removing whitespace. The ``chars`` argument
1003 is not a prefix or suffix; rather, all combinations of its
1004 values are stripped.
1005
1006 Returns
1007 -------
1008 out : ndarray
1009 Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
1010 depending on input types
1011
1012 See Also
1013 --------
1014 str.rstrip
1015
1016 Examples
1017 --------
1018 >>> import numpy as np
1019 >>> c = np.array(['aAaAaA', 'abBABba'])
1020 >>> c
1021 array(['aAaAaA', 'abBABba'], dtype='<U7')
1022 >>> np.strings.rstrip(c, 'a')
1023 array(['aAaAaA', 'abBABb'], dtype='<U7')
1024 >>> np.strings.rstrip(c, 'A')
1025 array(['aAaAa', 'abBABba'], dtype='<U7')
1026
1027 """
1028 if chars is None:
1029 return _rstrip_whitespace(a)
1030 return _rstrip_chars(a, chars)
1031
1032
1033@set_module("numpy.strings")

Callers 1

rstripMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…