@@ -82,7 +82,8 @@ def hpat_pandas_stringmethods_upper_impl(self):
8282
8383import numba
8484from numba .extending import overload_method
85- from numba .types import (Integer , NoneType , Omitted , StringLiteral , UnicodeType )
85+ from numba .types import (Boolean , Integer , NoneType ,
86+ Omitted , StringLiteral , UnicodeType )
8687
8788from sdc .datatypes .common_functions import TypeChecker
8889from sdc .datatypes .hpat_pandas_stringmethods_types import StringMethodsType
@@ -188,6 +189,57 @@ def hpat_pandas_stringmethods_{methodname}_impl(self{methodparams}):
188189"""
189190
190191
192+ @overload_method (StringMethodsType , 'endswith' )
193+ def hpat_pandas_stringmethods_endswith (self , pat , na = None ):
194+ """
195+ Pandas Series method :meth:`pandas.core.strings.StringMethods.endswith()` implementation.
196+
197+ Note: Unicode type of list elements are supported only. Numpy.NaN is not supported as elements.
198+
199+ .. only:: developer
200+
201+ Test: python -m sdc.runtests -k sdc.tests.test_series.TestSeries.test_series_endswith
202+
203+ Parameters
204+ ----------
205+ self: :class:`pandas.core.strings.StringMethods`
206+ input arg
207+ pat: :obj:`str`
208+ Character sequence
209+ na: :obj:`bool`
210+ Object shown if element tested is not a string
211+ *unsupported*
212+
213+ Returns
214+ -------
215+ :obj:`pandas.Series`
216+ returns :obj:`pandas.Series` object
217+ """
218+
219+ ty_checker = TypeChecker ('Method endswith().' )
220+ ty_checker .check (self , StringMethodsType )
221+
222+ if not isinstance (pat , (StringLiteral , UnicodeType )):
223+ ty_checker .raise_exc (pat , 'str' , 'pat' )
224+
225+ if not isinstance (na , (Boolean , NoneType , Omitted )) and na is not None :
226+ ty_checker .raise_exc (na , 'bool' , 'na' )
227+
228+ def hpat_pandas_stringmethods_endswith_impl (self , pat , na = None ):
229+ if na is not None :
230+ msg = 'Method endswith(). The object na\n expected: None'
231+ raise ValueError (msg )
232+
233+ item_endswith = len (self ._data )
234+ result = numpy .empty (item_endswith , numba .types .boolean )
235+ for idx , item in enumerate (self ._data ._data ):
236+ result [idx ] = item .endswith (pat )
237+
238+ return pandas .Series (result , self ._data ._index , name = self ._data ._name )
239+
240+ return hpat_pandas_stringmethods_endswith_impl
241+
242+
191243@overload_method (StringMethodsType , 'find' )
192244def hpat_pandas_stringmethods_find (self , sub , start = 0 , end = None ):
193245 """
0 commit comments