For each element in `a`, return a copy of the string where all characters occurring in the optional argument `deletechars` are removed, and the remaining characters have been mapped through the given translation table. Calls `str.translate` element-wise. Parameters ---
(a, table, deletechars=None)
| 1739 | |
| 1740 | @array_function_dispatch(_translate_dispatcher) |
| 1741 | def translate(a, table, deletechars=None): |
| 1742 | """ |
| 1743 | For each element in `a`, return a copy of the string where all |
| 1744 | characters occurring in the optional argument `deletechars` are |
| 1745 | removed, and the remaining characters have been mapped through the |
| 1746 | given translation table. |
| 1747 | |
| 1748 | Calls `str.translate` element-wise. |
| 1749 | |
| 1750 | Parameters |
| 1751 | ---------- |
| 1752 | a : array-like of str or unicode |
| 1753 | |
| 1754 | table : str of length 256 |
| 1755 | |
| 1756 | deletechars : str |
| 1757 | |
| 1758 | Returns |
| 1759 | ------- |
| 1760 | out : ndarray |
| 1761 | Output array of str or unicode, depending on input type |
| 1762 | |
| 1763 | See Also |
| 1764 | -------- |
| 1765 | str.translate |
| 1766 | |
| 1767 | """ |
| 1768 | a_arr = numpy.asarray(a) |
| 1769 | if issubclass(a_arr.dtype.type, str_): |
| 1770 | return _vec_string( |
| 1771 | a_arr, a_arr.dtype, 'translate', (table,)) |
| 1772 | else: |
| 1773 | return _vec_string( |
| 1774 | a_arr, a_arr.dtype, 'translate', [table] + _clean_args(deletechars)) |
| 1775 | |
| 1776 | |
| 1777 | @array_function_dispatch(_unary_op_dispatcher) |
no test coverage detected