Пример #1
0
def execute_binary_op_series_group_by(op, left, right, **kwargs):
    if left.index != right.index:
        raise ValueError('Cannot perform {} operation on two series with '
                         'different groupings'.format(type(op).__name__))
    result = execute_binary_op(op, make_selected_obj(left),
                               make_selected_obj(right), **kwargs)
    return result.groupby(left.index)
Пример #2
0
def execute_series_regex_search_gb(op, data, pattern, **kwargs):
    return execute_series_regex_search(
        op,
        make_selected_obj(data),
        getattr(pattern, 'obj', pattern),
        **kwargs,
    ).groupby(data.index)
Пример #3
0
    def execute_udf_node_groupby(op, *args, **kwargs):
        func = op.func

        # all grouping keys must be identical
        assert_identical_grouping_keys(*args)

        # we're performing a scalar operation on grouped column, so
        # perform the operation directly on the underlying Series
        # and regroup after it's finished
        args_objs = [make_selected_obj(arg) for arg in args]
        groupings = args[0].index
        return dd.map_partitions(func, *args_objs).groupby(groupings)
Пример #4
0
def execute_log_series_gb_series_gb(op, left, right, **kwargs):
    result = execute_node(op, make_selected_obj(left),
                          make_selected_obj(right), **kwargs)
    return result.groupby(left.index)
Пример #5
0
def execute_unary_op_series_gb(op, operand, **kwargs):
    result = execute_node(op, make_selected_obj(operand), **kwargs)
    return result.groupby(operand.index)
Пример #6
0
def execute_binary_op_simple_series_gb(op, left, right, **kwargs):
    result = execute_binary_op(op, left, make_selected_obj(right), **kwargs)
    return result.groupby(right.index)
Пример #7
0
def execute_cast_series_group_by(op, data, type, **kwargs):
    result = execute_cast_series_generic(op, make_selected_obj(data), type,
                                         **kwargs)
    return result.groupby(data.index)
Пример #8
0
def execute_series_group_by_negate(op, data, **kwargs):
    return execute_series_negate(
        op, make_selected_obj(data), **kwargs
    ).groupby(data.index)
Пример #9
0
def execute_day_of_week_name_series_group_by(op, data, **kwargs):
    return day_name(make_selected_obj(data).dt).groupby(data.index)
Пример #10
0
def execute_series_group_by_find_in_set(op, needle, haystack, **kwargs):
    pieces = [getattr(piece, 'obj', piece) for piece in haystack]
    return execute_series_find_in_set(op, make_selected_obj(needle), pieces,
                                      **kwargs).groupby(needle.index)
Пример #11
0
def execute_series_right_gb(op, data, nchars, **kwargs):
    return execute_series_right(op, make_selected_obj(data),
                                nchars).groupby(data.index)
Пример #12
0
def execute_series_regex_replace_gb(op, data, pattern, replacement, **kwargs):
    return execute_series_regex_replace(make_selected_obj(data), pattern,
                                        replacement,
                                        **kwargs).groupby(data.index)
Пример #13
0
def execute_series_regex_extract_gb(op, data, pattern, index, **kwargs):
    return execute_series_regex_extract(op, make_selected_obj(data), pattern,
                                        index, **kwargs).groupby(data.index)
Пример #14
0
def execute_string_ascii_group_by(op, data, **kwargs):
    return execute_string_ascii(op, make_selected_obj(data),
                                **kwargs).groupby(data.index)
Пример #15
0
def execute_string_like_series_groupby_string(op, data, pattern, escape,
                                              **kwargs):
    return execute_string_like_series_string(
        op, make_selected_obj(data), pattern, escape,
        **kwargs).groupby(data.grouper.groupings)
Пример #16
0
def execute_node_struct_field_series_group_by(op, data, **kwargs):
    field = op.field
    selected_obj = make_selected_obj(data)
    return (selected_obj.map(operator.itemgetter(field),
                             meta=selected_obj._meta).rename(field).groupby(
                                 data.index))
Пример #17
0
def _filtered_reduction(data, mask):
    return make_selected_obj(data)[mask.obj].groupby(data.index)
Пример #18
0
def execute_day_of_week_index_series_group_by(op, data, **kwargs):
    return (
        make_selected_obj(data)
        .dt.dayofweek.astype(np.int16)
        .groupby(data.index)
    )