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

Function swapcase

numpy/_core/strings.py:1162–1198  ·  view source on GitHub ↗

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

(a)

Source from the content-addressed store, hash-verified

1160@set_module("numpy.strings")
1161@array_function_dispatch(_unary_op_dispatcher)
1162def swapcase(a):
1163 """
1164 Return element-wise a copy of the string with
1165 uppercase characters converted to lowercase and vice versa.
1166
1167 Calls :meth:`str.swapcase` element-wise.
1168
1169 For 8-bit strings, this method is locale-dependent.
1170
1171 Parameters
1172 ----------
1173 a : array-like, with ``StringDType``, ``bytes_``, or ``str_`` dtype
1174 Input array.
1175
1176 Returns
1177 -------
1178 out : ndarray
1179 Output array of ``StringDType``, ``bytes_`` or ``str_`` dtype,
1180 depending on input types
1181
1182 See Also
1183 --------
1184 str.swapcase
1185
1186 Examples
1187 --------
1188 >>> import numpy as np
1189 >>> c=np.array(['a1B c','1b Ca','b Ca1','cA1b'],'S5'); c
1190 array(['a1B c', '1b Ca', 'b Ca1', 'cA1b'],
1191 dtype='|S5')
1192 >>> np.strings.swapcase(c)
1193 array(['A1b C', '1B cA', 'B cA1', 'Ca1B'],
1194 dtype='|S5')
1195
1196 """
1197 a_arr = np.asarray(a)
1198 return _vec_string(a_arr, a_arr.dtype, 'swapcase')
1199
1200
1201@set_module("numpy.strings")

Callers 1

swapcaseMethod · 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…