Ejemplo n.º 1
0
        else:
            out_coords[index] = c2
            out_data[index] = finish_last_data[iter]
            iter += 1
            c2 = finish_last_coords[iter]
    if iter < finish_last_len:
        index += 1
        end_index = index + finish_last_len - iter
        out_coords[index:end_index] = finish_last_coords[iter:]
        out_data[index:end_index] = finish_last_data[iter:]
    return ret_out_coords[:, :end_index], out_data[:end_index]


SparseExtensionArray._add_arithmetic_ops()
SparseExtensionArray._add_comparison_ops()
registry.register(SparseArrayType)


#@jit(void(float64[:], int64[:], int64, float64), parallel=True, nogil=True, nopython=True)
@jit(cache=True, nogil=True, nopython=True)
def iter(data, coords, length, na_value):
    coords_len = data.shape[0]
    coords_iter = 0
    for i in range(length):
        if coords_iter >= coords_len:
            yield na_value
        elif coords[coords_iter] != i:
            yield na_value
        else:
            val = data[coords_iter]
            coords_iter += 1
Ejemplo n.º 2
0
            return self._maybe_mask_result(result, mask, other, op_name)

        name = '__{name}__'.format(name=op.__name__)
        return set_function_name(integer_arithmetic_method, name, cls)


IntegerArray._add_arithmetic_ops()
IntegerArray._add_comparison_ops()

module = sys.modules[__name__]

# create the Dtype
_dtypes = {}
for dtype in [
        'int8', 'int16', 'int32', 'int64', 'uint8', 'uint16', 'uint32',
        'uint64'
]:

    if dtype.startswith('u'):
        name = "U{}".format(dtype[1:].capitalize())
    else:
        name = dtype.capitalize()
    classname = "{}Dtype".format(name)
    attributes_dict = {'type': getattr(np, dtype), 'name': name}
    dtype_type = type(classname, (_IntegerDtype, ), attributes_dict)
    setattr(module, classname, dtype_type)

    # register
    registry.register(dtype_type)
    _dtypes[dtype] = dtype_type()
Ejemplo n.º 3
0
        op_name = ops._get_op_name(op, True)
        return set_function_name(_binop, op_name, cls)

    @classmethod
    def _create_arithmetic_method(cls, op):
        return cls._create_method(op)

    @classmethod
    def _create_comparison_method(cls, op):
        return cls._create_method(op, coerce_to_dtype=False)


PintArray._add_arithmetic_ops()
PintArray._add_comparison_ops()
# register
registry.register(PintType)


@register_dataframe_accessor("pint")
class PintDataFrameAccessor(object):
    def __init__(self, pandas_obj):
        self._obj = pandas_obj

    def quantify(self, ureg, level=-1):
        df = self._obj
        Q_ = ureg.Quantity
        df_columns = df.columns.to_frame()
        unit_col_name = df_columns.columns[level]
        units = df_columns[unit_col_name]
        df_columns = df_columns.drop(columns=unit_col_name)
        df_columns.values
Ejemplo n.º 4
0
        name = '__{name}__'.format(name=op.__name__)
        return set_function_name(integer_arithmetic_method, name, cls)


IntegerArray._add_arithmetic_ops()
IntegerArray._add_comparison_ops()


module = sys.modules[__name__]


# create the Dtype
_dtypes = {}
for dtype in ['int8', 'int16', 'int32', 'int64',
              'uint8', 'uint16', 'uint32', 'uint64']:

    if dtype.startswith('u'):
        name = "U{}".format(dtype[1:].capitalize())
    else:
        name = dtype.capitalize()
    classname = "{}Dtype".format(name)
    attributes_dict = {'type': getattr(np, dtype),
                       'name': name}
    dtype_type = type(classname, (_IntegerDtype, ), attributes_dict)
    setattr(module, classname, dtype_type)

    # register
    registry.register(dtype_type)
    _dtypes[dtype] = dtype_type()