For each element in `a`, return a copy with the trailing characters removed. Calls `str.rstrip` element-wise. Parameters ---------- a : array-like of str or unicode chars : str or unicode, optional The `chars` argument is a string specifying the set of c
(a, chars=None)
| 1462 | |
| 1463 | @array_function_dispatch(_strip_dispatcher) |
| 1464 | def rstrip(a, chars=None): |
| 1465 | """ |
| 1466 | For each element in `a`, return a copy with the trailing |
| 1467 | characters removed. |
| 1468 | |
| 1469 | Calls `str.rstrip` element-wise. |
| 1470 | |
| 1471 | Parameters |
| 1472 | ---------- |
| 1473 | a : array-like of str or unicode |
| 1474 | |
| 1475 | chars : str or unicode, optional |
| 1476 | The `chars` argument is a string specifying the set of |
| 1477 | characters to be removed. If omitted or None, the `chars` |
| 1478 | argument defaults to removing whitespace. The `chars` argument |
| 1479 | is not a suffix; rather, all combinations of its values are |
| 1480 | stripped. |
| 1481 | |
| 1482 | Returns |
| 1483 | ------- |
| 1484 | out : ndarray |
| 1485 | Output array of str or unicode, depending on input type |
| 1486 | |
| 1487 | See Also |
| 1488 | -------- |
| 1489 | str.rstrip |
| 1490 | |
| 1491 | Examples |
| 1492 | -------- |
| 1493 | >>> c = np.array(['aAaAaA', 'abBABba'], dtype='S7'); c |
| 1494 | array(['aAaAaA', 'abBABba'], |
| 1495 | dtype='|S7') |
| 1496 | >>> np.char.rstrip(c, b'a') |
| 1497 | array(['aAaAaA', 'abBABb'], |
| 1498 | dtype='|S7') |
| 1499 | >>> np.char.rstrip(c, b'A') |
| 1500 | array(['aAaAa', 'abBABba'], |
| 1501 | dtype='|S7') |
| 1502 | |
| 1503 | """ |
| 1504 | a_arr = numpy.asarray(a) |
| 1505 | return _vec_string(a_arr, a_arr.dtype, 'rstrip', (chars,)) |
| 1506 | |
| 1507 | |
| 1508 | @array_function_dispatch(_split_dispatcher) |