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 array
myarray = np.array(["hello", "theophilus ,", 'HOW', "are", "you today?"])
# implementing the char.lower() function
print(np.char.lower(myarray))

Explanation

  • Line 1: We import Python’s numpy module as np.
  • Line 4: We create an array myarray using the array() 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. The print function is used to display the result.
New on Educative
Learn to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources