char.endswith(a, suffix, start=0, end=None)
The char.endswith() function takes the following parameter values:
a: This is the input array.suffix: This is the character string from the input array to be checked for.start: With an optional start, the test to test begins at that position. end: With an optional end, the comparison stops at the given position.The char.endswith() function returns an output array having Boolean values.
import numpy as np# creating an input arraya = np.array(["Hello", "Red", "Goat", "Tired"])# implementing the char.endwith() function to check if the elements ends with "ed"myarray = np.char.endswith(a, "ed", start=1, end=3 )# printing the resultprint(myarray)
numpy module.a using the array() function.char.endswith() function to check if the string character ed appears in each element of the input array a. We start from the second character (index 1)to the third character (index 2) of each element. We assign the result to a variable, myarray.myarray.