![]() |
VOOZH | about |
The np.char.endswith() method is used to check whether each string in a NumPy array ends with a specified substring.
For Example: This example checks whether each string in a 1D array ends with the letter "s".
Array: ['cats' 'dogs' 'fish'] Result: [ True True False]
Explanation:
np.char.endswith(a, suffix)
Parameters:
Return Value: ndarray of bool -> Boolean array indicating whether each string ends with the given substring.
Example 1: This example checks if strings in a 1D array end with "ks".
[ True False True]
Example 2: This example checks if strings in the array end with the digit "1".
[ True False False True]
Example 3: This example shows that the method is case-sensitive.
[ True False True]