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:
Python - NumPy Code Editor:
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework