(index)
return types.Array(numba_index_type, 1, 'C')
Deduces native Numba type used to represent index Python object
Deduces native Numba type used to represent index Python object
Deduces native Numba type used to represent index Python object
def _infer_index_type(index):
    """ Deduces native Numba type used to represent index Python object """

    index_is_named = index.name is not None
    # more specific types go first (e.g. RangeIndex is subtype of Int64Index)
    if isinstance(index, pd.RangeIndex):
        # depending on actual index value unbox to diff types: none-index if it matches
        # positions or to RangeIndexType in general case
        if (index.start == 0 and index.step == 1):
            return PositionalIndexType(is_named=index_is_named)
        else:
            return RangeIndexType(is_named=index_is_named)

    # for unsupported pandas indexes we explicitly unbox to None
    if isinstance(index, pd.DatetimeIndex):
        return types.none

    if isinstance(index, pd.Int64Index):
        index_data_type = numba.typeof(index._data)
        return Int64IndexType(index_data_type, is_named=index_is_named)

    if index.dtype == np.dtype('O'):
        # TO-DO: should we check that all elements are strings?
        if len(index) > 0 and isinstance(index[0], str):
            return string_array_type
        elif len(index) == 0:
            return EmptyIndexType(is_named=index_is_named)
        else:
            assert False, f"Unboxing failed: cannot infer type for index:\n\t{index}"
            return types.none

    numba_index_type = numpy_support.from_dtype(index.dtype)
    return types.Array(numba_index_type, 1, 'C')
def _infer_index_type ( index ) : index_is_named = index . name is not None # more specific types go first (e.g. RangeIndex is subtype of Int64Index) if isinstance ( index , pd . RangeIndex ) : # depending on actual index value unbox to diff types: none-index if it matches # positions or to RangeIndexType in general case if ( index . start == 0 and index . step == 1 ) : return PositionalIndexType ( is_named = index_is_named ) else : return RangeIndexType ( is_named = index_is_named ) # for unsupported pandas indexes we explicitly unbox to None if isinstance ( index , pd . DatetimeIndex ) : return types . none if isinstance ( index , pd . Int64Index ) : index_data_type = numba . typeof ( index . _data ) return Int64IndexType ( index_data_type , is_named = index_is_named ) if index . dtype == np . dtype ( 'O' ) : # TO-DO: should we check that all elements are strings? if len ( index ) > 0 and isinstance ( index [ 0 ] , str ) : return string_array_type elif len ( index ) == 0 : return EmptyIndexType ( is_named = index_is_named ) else : assert False , f"Unboxing failed: cannot infer type for index:\n\t{index}" return types . none numba_index_type = numpy_support . from_dtype ( index . dtype ) return types . Array ( numba_index_type , 1 , 'C' )