numpy.strings.endswith — NumPy v2.6.dev0 Manual

strings.endswith(a, suffix, start=0, end=None)

[source]

#

Returns a boolean array which is True where the string element in a ends with suffix, otherwise False.

Parameters:aarray-like, with StringDType, bytes_, or str_ dtypesuffixarray-like, with StringDType, bytes_, or str_ dtypestart, endarray_like, with any integer dtypeWith start, test beginning at that position. With end, stop comparing at that position.

Returns:outndarrayOutput array of bools

Examples

>>> importnumpyasnp>>> s=np.array(['foo','bar'])>>> sarray(['foo', 'bar'], dtype='<U3')>>> np.strings.endswith(s,'ar')array([False, True])>>> np.strings.endswith(s,'a',start=1,end=2)array([False, True])