Overview
- The isupper() function of numpy.strings module checks whether all the strings elements of a NumPy array is made of all uppercase letters.
Example
# Example Python program that finds whether
# the string elements of an ndarray consists of
# all uppercase elements using the function
# numpy.strings.isupper()
import numpy
# Create a NumPy array of ASCII strings
asciiStrings = numpy.ndarray(shape = (2, 2),
dtype = numpy.dtype('S10'))
asciiStrings[0][0] = "abCD"
asciiStrings[0][1] = "xYz"
asciiStrings[1][0] = "ALL"
asciiStrings[1][1] = "none"
# Find whether the strings contain all uppercase letters
res = numpy.strings.isupper(asciiStrings)
print("ASCII strings:")
print(asciiStrings)
print("Are they comprised of all uppercase letters:")
print(res)Output
ASCII strings:
[[b'abCD' b'xYz']
[b'ALL' b'none']]
Are they comprised of all uppercase letters:
[[False False]
[ True False]]