Please note, this is a STATIC archive of website www.w3resource.com from 19 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
w3resource

NumPy: swapcase() function

numpy.core.defchararray.swapcase() function

The numpy.core.defchararray.swapcase() function returns 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.

Version: 1.15.0

Syntax:

numpy.core.defchararray.swapcase(a)

Parameter:

Name Description Required /
Optional
a Input array. [array_like, {str, unicode}]

Return value:

out [ndarray, {str, unicode}] Output array of str or unicode, depending on input type.

Example: numpy.swapcase() function

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

Pictorial Presentation:

NumPy String operation: swapcase() function

Python - NumPy Code Editor:

Previous: strip()
Next: title()