![]() |
VOOZH | about |
The numpy.char.upper() function is used to convert all characters in the elements of a NumPy string array to uppercase. It works element-wise and returns a new array with the modified strings.
This example shows how to use np.char.upper() to convert lowercase characters into uppercase.
['HELLO WORLD']
numpy.char.upper(arr)
Example 1: In this example, we convert alphanumeric strings to uppercase.
Array: ['p4q r' '4q rp' 'q rp4' 'rp4q'] Result: ['P4Q R' '4Q RP' 'Q RP4' 'RP4Q']
Example 2: In this example, we convert a simple word array into uppercase.
Array: ['geeks' 'for' 'geeks'] Result: ['GEEKS' 'FOR' 'GEEKS']
Example 3: Here, we apply upper() to sentences with mixed cases.
Array: ['NumPy is Powerful' 'python is fun'] Result: ['NUMPY IS POWERFUL' 'PYTHON IS FUN']