Python | Numpy np.char.endswith () method



With the method np.char.endswith() we can get a boolean array when values ​​end with a specific character passed to np.char.endswith ( ) .

Syntax: np.char.endswith ()
Return: Return the boolean array when values ​​ends with a value.

Example # 1:
In this example, we see that using np.char.endswith () we can get a boolean array if it matches the string values ​​in np.char.endswith () .

# NumPy import

import numpy as np

 
# using the np.char.endswith () method

a = np.array ([ `geeks` , `for` , ` geeks` ])

gfg = np.char.endswith (a, `ks` )

 

print (gfg)

Output:

[True False True]

Example # 2:

# NumPy import

import numpy as np

  
# using the np.char.endswith () method

a = np.array ([[ `geeks` , ` for` , `geeks` ], [ `jitender` , `author` , ` gfg` ]])

gfg = np.char.endswith (a, `r` )

  

print (gfg)

Output:

[[False True False]
[True True False]]