What is the numpy.char.lower() function in Python?
Overview
Numpy’s char.lower() function in Python is used to convert the elements of an array to lowercase.
Syntax
char.lower(a)
Parameter
The char.lower() function takes a single parameter value (a) that represents the input array of strings or Unicode.
Return value
The char.lower() function returns an array of strings or Unicode, depending on the input type of a.
Code
import numpy as np# creating an arraymyarray = np.array(["hello", "theophilus ,", 'HOW', "are", "you today?"])# implementing the char.lower() functionprint(np.char.lower(myarray))
Explanation
- Line 1: We import Python’s
numpymodule asnp. - Line 4: We create an array
myarrayusing thearray()function and initialize it with five strings. - Line 7: We use the
char.lower()function to covert the elements of the array into lower case. Theprintfunction is used to display the result.