What is the numpy.char.isalpha() function in Python?
char.isalpha(a)
The syntax for the char.isalpha() function
Parameter value
The char.isalpha() function takes a single parameter a which is the array of strings.
Return value
The char.isalpha() function returns an array of boolean values of the same shape as the input array a.
Example
import numpy as np# creating an input arraya = np.array(['The', "342", "Hello", "A", "100"])# implementing the char.isalpha() functionmyarray = np.char.isalpha(a)# printing the input arrayprint(a)# printing the output arraysprint(myarray)
Explanation
Here is a line-by-line explanation of the code above:
- Line 1: We import the
numpymodule. - Line 3: We create an input array
ausing thearray()function. - Line 6: We implement the
char.isupper()function on the input array. The result is assigned to a variablemyarray. - Line 9: We print the input array
a. - Line 12: We print the output array
myarray.