@@ -83,6 +83,7 @@ def hpat_pandas_stringmethods_upper_impl(self):
8383
8484import numba
8585from numba .extending import overload_method
86+ from numba .errors import TypingError
8687
8788from sdc .datatypes .hpat_pandas_stringmethods_types import StringMethodsType
8889
@@ -186,6 +187,42 @@ def hpat_pandas_stringmethods_{methodname}_impl(self{methodparams}):
186187"""
187188
188189
190+ @overload_method (StringMethodsType , 'len' )
191+ def hpat_pandas_stringmethods_len (self ):
192+ """
193+ Pandas Series method :meth:`pandas.core.strings.StringMethods.len()` implementation.
194+
195+ Note: Unicode type of list elements are supported only. Numpy.NaN is not supported as elements.
196+
197+ .. only:: developer
198+
199+ Test: python -m sdc.runtests sdc.tests.test_series.TestSeries.test_series_str_len1
200+
201+ Parameters
202+ ----------
203+ self: :class:`pandas.core.strings.StringMethods`
204+ input arg
205+
206+ Returns
207+ -------
208+ :obj:`pandas.Series`
209+ returns :obj:`pandas.Series` object
210+ """
211+
212+ if not isinstance (self , StringMethodsType ):
213+ raise TypingError ('Method len(). The object must be a pandas.core.strings. Given: {}' .format (self ))
214+
215+ def hpat_pandas_stringmethods_len_impl (self ):
216+ item_count = len (self ._data )
217+ result = numpy .empty (item_count , numba .types .int64 )
218+ for idx , item in enumerate (self ._data ._data ):
219+ result [idx ] = len (item )
220+
221+ return pandas .Series (result , name = self ._data ._name )
222+
223+ return hpat_pandas_stringmethods_len_impl
224+
225+
189226def _hpat_pandas_stringmethods_autogen (method_name ):
190227 """"
191228 The function generates a function for 'method_name' from source text that is created on the fly.
@@ -231,7 +268,7 @@ def _hpat_pandas_stringmethods_autogen(method_name):
231268 This is the list of function which are autogenerated to be used from Numba directly.
232269"""
233270
234- _hpat_pandas_stringmethods_autogen_exceptions = ['split' , 'len' , ' get' , 'replace' ]
271+ _hpat_pandas_stringmethods_autogen_exceptions = ['split' , 'get' , 'replace' ]
235272
236273for method_name in _hpat_pandas_stringmethods_autogen_methods :
237274 if not (method_name .startswith ('__' ) or method_name in _hpat_pandas_stringmethods_autogen_exceptions ):
0 commit comments