(self, dtype)
Intel Scalable Dataframe Compiler Developer Guide
    *************************************************
    Parallel replacement of numpy.astype.

    .. only:: developer
       Test: python -m sdc.runtests sdc.tests.test_sdc_numpy -k astype
Intel Scalable Dataframe Compiler Developer Guide
    *************************************************
    Parallel replacement of numpy.astype.
Intel Scalable Dataframe Compiler Developer Guide ************************************************* Parallel replacement of numpy . astype .
def sdc_astype_overload(self, dtype):
    """
    Intel Scalable Dataframe Compiler Developer Guide
    *************************************************
    Parallel replacement of numpy.astype.

    .. only:: developer
       Test: python -m sdc.runtests sdc.tests.test_sdc_numpy -k astype

    """

    ty_checker = TypeChecker("numpy-like 'astype'")
    valid_self_types = sdc_pandas_df_column_types
    if not (isinstance(self, valid_self_types)):
        return None

    if isinstance(self, StringArrayType):
        return SDCLimitation("numpy_like.astype not implemented for string data")

    accepted_dtype_types = (types.functions.NumberClass, types.Function, types.StringLiteral)
    if not isinstance(dtype, accepted_dtype_types):
        def impl(self, dtype):
            return literally(dtype)

        return impl

    if not isinstance(dtype, accepted_dtype_types):
        ty_checker.raise_exc(dtype, 'string or type', 'dtype')

    if (
        (isinstance(dtype, types.Function) and dtype.typing_key == str) or
        (isinstance(dtype, types.StringLiteral) and dtype.literal_value == 'str')
    ):
        def sdc_astype_number_to_string_impl(self, dtype):
            num_bytes = 0
            arr_len = len(self)

            # Get total bytes for new array
            for i in np.arange(arr_len):    # FIXME_Numba#6969: prange segfaults, use it when resolved
                item = self[i]
                num_bytes += get_utf8_size(str(item))

            data = pre_alloc_string_array(arr_len, num_bytes)

            for i in range(arr_len):
                item = self[i]
                data[i] = str(item)  # TODO: check NA

            return data

        return sdc_astype_number_to_string_impl

    if (isinstance(self, types.Array)
            and isinstance(dtype, (types.StringLiteral, types.functions.NumberClass))):
        def sdc_astype_number_impl(self, dtype):
            arr = numpy.empty(len(self), dtype=numpy.dtype(dtype))
            for i in numba.prange(len(self)):
                arr[i] = self[i]

            return arr

        return sdc_astype_number_impl
def sdc_astype_overload ( self , dtype ) : ty_checker = TypeChecker ( "numpy-like 'astype'" ) valid_self_types = sdc_pandas_df_column_types if not ( isinstance ( self , valid_self_types ) ) : return None if isinstance ( self , StringArrayType ) : return SDCLimitation ( "numpy_like.astype not implemented for string data" ) accepted_dtype_types = ( types . functions . NumberClass , types . Function , types . StringLiteral ) if not isinstance ( dtype , accepted_dtype_types ) : def impl ( self , dtype ) : return literally ( dtype ) return impl if not isinstance ( dtype , accepted_dtype_types ) : ty_checker . raise_exc ( dtype , 'string or type' , 'dtype' ) if ( ( isinstance ( dtype , types . Function ) and dtype . typing_key == str ) or ( isinstance ( dtype , types . StringLiteral ) and dtype . literal_value == 'str' ) ) : def sdc_astype_number_to_string_impl ( self , dtype ) : num_bytes = 0 arr_len = len ( self ) # Get total bytes for new array for i in np . arange ( arr_len ) : # FIXME_Numba#6969: prange segfaults, use it when resolved item = self [ i ] num_bytes += get_utf8_size ( str ( item ) ) data = pre_alloc_string_array ( arr_len , num_bytes ) for i in range ( arr_len ) : item = self [ i ] data [ i ] = str ( item ) # TODO: check NA return data return sdc_astype_number_to_string_impl if ( isinstance ( self , types . Array ) and isinstance ( dtype , ( types . StringLiteral , types . functions . NumberClass ) ) ) : def sdc_astype_number_impl ( self , dtype ) : arr = numpy . empty ( len ( self ) , dtype = numpy . dtype ( dtype ) ) for i in numba . prange ( len ( self ) ) : arr [ i ] = self [ i ] return arr return sdc_astype_number_impl