On this article, we’re going to see how we are going to return a boolean array which is True the place the string ingredient within the array ends with a suffix in Python.
numpy.char.endswith()
numpy.char.endswith() return True if the weather finish with the given substring in any other case it is going to return False.
Syntax : np.char.endswith(input_numpy_array,’substring’)
Parameters:
- input_numpy_array refers back to the numpy array with strings
- substring is in contrast with all parts current in an array
Return: Return the boolean array which incorporates “True” if a substring is current as a suffix and “False” if a substring isn’t current as a suffix.
Instance 1:
On this instance, we’re making a NumPy array with 5 strings and checking the weather’ ends with ‘ks’.
Python3
|
Output:
[False False True False True]
Instance 2:
On this instance, we’re making a NumPy array with 5 strings and checking the ingredient’s ends with ‘o’.
Python3
|
Output:
[ True True False False False]