MCPcopy Create free account
hub / github.com/numpy/numpy / swapcase

Function swapcase

numpy/core/defchararray.py:1659–1693  ·  view source on GitHub ↗

Return element-wise a copy of the string with uppercase characters converted to lowercase and vice versa. Calls `str.swapcase` element-wise. For 8-bit strings, this method is locale-dependent. Parameters ---------- a : array_like, {str, unicode} Input array.

(a)

Source from the content-addressed store, hash-verified

1657
1658@array_function_dispatch(_unary_op_dispatcher)
1659def swapcase(a):
1660 """
1661 Return element-wise a copy of the string with
1662 uppercase characters converted to lowercase and vice versa.
1663
1664 Calls `str.swapcase` element-wise.
1665
1666 For 8-bit strings, this method is locale-dependent.
1667
1668 Parameters
1669 ----------
1670 a : array_like, {str, unicode}
1671 Input array.
1672
1673 Returns
1674 -------
1675 out : ndarray, {str, unicode}
1676 Output array of str or unicode, depending on input type
1677
1678 See Also
1679 --------
1680 str.swapcase
1681
1682 Examples
1683 --------
1684 >>> c=np.array(['a1B c','1b Ca','b Ca1','cA1b'],'S5'); c
1685 array(['a1B c', '1b Ca', 'b Ca1', 'cA1b'],
1686 dtype='|S5')
1687 >>> np.char.swapcase(c)
1688 array(['A1b C', '1B cA', 'B cA1', 'Ca1B'],
1689 dtype='|S5')
1690
1691 """
1692 a_arr = numpy.asarray(a)
1693 return _vec_string(a_arr, a_arr.dtype, 'swapcase')
1694
1695
1696@array_function_dispatch(_unary_op_dispatcher)

Callers 1

swapcaseMethod · 0.85

Calls 1

_vec_stringFunction · 0.90

Tested by

no test coverage detected