@sdc_overload(operator.getitem)
def hpat_pandas_series_getitem(self, idx):
if not isinstance(self, SeriesType):
return None
def hpat_pandas_series_getitem_index_impl(self, idx):
index = self._index
mask = numpy.empty(len(self._data), numpy.bool_)
for i in numba.prange(len(index)):
mask[i] = index[i] == idx
if mask.sum() == 1:
return self._data[numpy.argmax(mask == True)]
else:
return pandas.Series(data=self._data[mask], index=index[mask], name=self._name)
return hpat_pandas_series_getitem_index_impl
Here, I use sdc_overload (which call overload method internally), but I want to return two types, int or series, according to different runtime value. How to do this? Right now, Numba complains about “Can’t unify return type from the following types: int64, series(int64, array(int64, 1d, C), StringArrayType(), True)”. And I could not differ into two implmentations just according to arg types.