What is the numpy.char.isalnum() function in Python?

Overview

The char.isalnum() function in the numpy package returns True if all characters of a string are either alphabetic, numeric, or alphanumeric and there is at least one character. Otherwise, it returns False.

Syntax

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

Parameter value

  • a: This method takes a single parameter value that represents the input array of strings or Unicode.

Return value

The char.isalnum() function returns an output array containing boolean values regarding each input array element.

Example

import numpy as np
# creating an input array
a = np.array(['The123', "###", "Hello", "%%%", "14"])
# implementing the char.isalnum() function
myarray = np.char.isalnum(a)
# printing the input array
print(a)
# printing the output arrays
print(myarray)

Free Resources