VOOZH about

URL: https://www.geeksforgeeks.org/python/numpy-string-operations-upper-function/

⇱ upper() function - NumPy - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

upper() function - NumPy

Last Updated : 27 Sep, 2025

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.


Output
['HELLO WORLD']

Syntax

numpy.char.upper(arr)
  • Parameters:arr (array_like) -> Input array of strings.
  • Return Value:ndarray -> Array with all string elements converted to uppercase.

Examples

Example 1: In this example, we convert alphanumeric strings to uppercase.


Output
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.


Output
Array: ['geeks' 'for' 'geeks']
Result: ['GEEKS' 'FOR' 'GEEKS']

Example 3: Here, we apply upper() to sentences with mixed cases.


Output
Array: ['NumPy is Powerful' 'python is fun']
Result: ['NUMPY IS POWERFUL' 'PYTHON IS FUN']
Comment