Signup/Sign In

NumPy isupper() function

In this tutorial, we will cover isupper() function of the char module available in the Numpy library.

The isupper() function returns True for each string element of the ndarray, if all the characters of the string element are in uppercase. Otherwise, this function will return False. For empty strings and for special characters too, it will return False.

This function calls str.isupper internally for each element of the array.

This function is locale-dependent for an 8-bit string.

Syntax of numpy.char.isupper():

The syntax required to use this function is as follows:


The above syntax indicates that isupper() function takes a single parameter.

In the above syntax, the argument arr is mainly used to indicate the input array of strings on which this function will be applied.

Returned Values:

This function will return an output array of boolean values, with True and False values corresponding to every string element, based on whether the string is in uppercase or not.

Example 1: With a string

In the below example we will use the isupper() function with a simple string:

import numpy as np

string1 = "THIS IS AN APPLE"
x = np.char.isupper(string1)
print("After applying isupper() Function:")

After applying isupper() Function:

Example 2:

In the below code snippet we will use the isupper() function on an array of strings:

import numpy as np

inp_ar = np.array(['ss4Q', 'OOPS', 'WooHoo2']) 
print ("The input array : \n", inp_ar) 

output = np.char.isupper(inp_ar) 
print ("The output array :\n", output) 

The input array :
['ss4Q' 'OOPS' 'WooHoo2']
The output array :
[False True False]


In this tutorial we learned about the isupper() function in the Numpy library. We covered how it is used with its syntax and values returned by this function. There are two examples in order to gain an understanding of the working of this function.

About the author:
Aspiring Software developer working as a content writer. I like computer related subjects like Computer Networks, Operating system, CAO, Database, and I am also learning Python.