What is the numpy.char.islower() function from NumPy in Python?

Overview

The char.islower() function in Python returns True for each element of an input array of strings. This happens if all the cased characters in the string are lowercase and there is at least one cased character. Otherwise, the function returns False.

Syntax

char.islower(a)
Syntax for the char.islower() function

Parameter value

The char.islower() function takes a single parameter value, a, which represents the input array of strings.

Return value

The char.islower() function returns an output array of boolean values with the same shape as the input array a.

Example

import numpy as np
# creating an input array
a = np.array(['HELLO', "hello", "HI", "hi", "A", "a"])
# implementing the char.islower() function
myarray = np.char.islower(a)
# printing the input array
print(a)
# printing the output arrays
print(myarray)

Explanation

  • Line 1: We import thenumpymodule.
  • Line 3: We create an input array a using the array() function.
  • Line 6: We apply the char.islower() function on the input array. The result is assigned to the myarray variable.
  • Line 9: We print the input array a.
  • Line 12: We print the myarrayoutput array.
  • Free Resources