NumPy

Previous topic

numpy.char.strip

Next topic

numpy.char.title

This is documentation for an old release of NumPy (version 1.19). Read this page in the documentation of the latest stable release (version 2.2).

numpy.char.swapcase

numpy.char.swapcase(a)

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
aarray_like, {str, unicode}

Input array.

Returns
outndarray, {str, unicode}

Output array of str or unicode, depending on input type

See also

str.swapcase

Examples

>>>
>>> c=np.array(['a1B c','1b Ca','b Ca1','cA1b'],'S5'); c
array(['a1B c', '1b Ca', 'b Ca1', 'cA1b'],
    dtype='|S5')
>>> np.char.swapcase(c)
array(['A1b C', '1B cA', 'B cA1', 'Ca1B'],
    dtype='|S5')