NumPy String: numpy.char.upper() function
numpy.char.upper() function
The numpy.char.upper() function is used to convert all the lowercase characters in a given array or string to uppercase. It returns an array of the same shape.
The function is useful when we want to convert all lowercase characters in a string or array to uppercase to normalize the data.
Syntax:
numpy.char.upper(a)
Parameter:
Name | Description | Required / Optional |
---|---|---|
a | Input array. | array_like, {str, unicode} |
Return value:
Output array of str or unicode, depending on input type.
Example: Converting strings to uppercase using numpy.char.upper()
In the above example the numpy.char.upper() function converts a numpy array of strings to uppercase.
Pictorial Presentation:

Example: Converting strings to uppercase using numpy.char.upper()
The above code demonstrates the use of the numpy.char.upper() function to convert a numpy array of strings to uppercase.
Python - NumPy Code Editor:
Previous:
translate()
Next:
zfill()
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics