Skip to content

apply_reduce module

Generic Numba-compiled functions for mapping, applying, and reducing.


all_reduce_nb function

all_reduce_nb(
    arr
)

Get whether all of the elements are True.


any_reduce_nb function

any_reduce_nb(
    arr
)

Get whether any of the elements are True.


apply_and_reduce_1d_meta_nb function

apply_and_reduce_1d_meta_nb(
    col,
    apply_func_nb,
    apply_args,
    reduce_func_nb,
    reduce_args
)

Meta version of apply_and_reduce_1d_nb().

apply_func_nb must accept the column index, the array, and *apply_args. Must return an array.

reduce_func_nb must accept the column index, the array of results from apply_func_nb, and *reduce_args. Must return a single value.


apply_and_reduce_1d_nb function

apply_and_reduce_1d_nb(
    arr,
    apply_func_nb,
    apply_args,
    reduce_func_nb,
    reduce_args
)

Apply apply_func_nb and reduce into a single value using reduce_func_nb.

apply_func_nb must accept the array and *apply_args. Must return an array.

reduce_func_nb must accept the array of results from apply_func_nb and *reduce_args. Must return a single value.


apply_and_reduce_meta_nb function

apply_and_reduce_meta_nb(
    n_cols,
    apply_func_nb,
    apply_args,
    reduce_func_nb,
    reduce_args
)

2-dim version of apply_and_reduce_1d_meta_nb().


apply_and_reduce_nb function

apply_and_reduce_nb(
    arr,
    apply_func_nb,
    apply_args,
    reduce_func_nb,
    reduce_args
)

2-dim version of apply_and_reduce_1d_nb().


apply_meta_nb function

apply_meta_nb(
    target_shape,
    apply_func_nb,
    *args
)

Meta version of apply_nb() that prepends the column index to the arguments of apply_func_nb.


apply_nb function

apply_nb(
    arr,
    apply_func_nb,
    *args
)

Apply function on each column of an object.

apply_func_nb must accept the array and *args. Must return a single value or an array of shape a.shape[1].


argmax_reduce_nb function

argmax_reduce_nb(
    arr
)

Get position of max.


argmin_reduce_nb function

argmin_reduce_nb(
    arr
)

Get position of min.


corr_reduce_grouped_meta_nb function

corr_reduce_grouped_meta_nb(
    group_idxs,
    group,
    arr1,
    arr2
)

Get correlation coefficient. Ignores NaN.


count_reduce_nb function

count_reduce_nb(
    arr
)

Get count. Ignores NaN.


cov_reduce_grouped_meta_nb function

cov_reduce_grouped_meta_nb(
    group_idxs,
    group,
    arr1,
    arr2,
    ddof
)

Get correlation coefficient. Ignores NaN.


describe_reduce_nb function

describe_reduce_nb(
    arr,
    perc,
    ddof
)

Get descriptive statistics. Ignores NaN.

Numba equivalent to pd.Series(arr).describe(perc).


first_index_reduce_nb function

first_index_reduce_nb(
    arr
)

Get index of first non-NA element.


first_reduce_nb function

first_reduce_nb(
    arr
)

Get first non-NA element.


flatten_forder_nb function

flatten_forder_nb(
    arr
)

Flatten the array in F order.


flatten_grouped_nb function

flatten_grouped_nb(
    arr,
    group_map,
    in_c_order
)

Flatten each group of columns.


flatten_uniform_grouped_nb function

flatten_uniform_grouped_nb(
    arr,
    group_map,
    in_c_order
)

Flatten each group of columns of the same length.


groupby_reduce_1d_meta_nb function

groupby_reduce_1d_meta_nb(
    col,
    group_map,
    reduce_func_nb,
    *args
)

Meta version of groupby_reduce_1d_nb().

reduce_func_nb must accept the array of indices in the group, the group index, the column index, and *args. Must return a single value.


groupby_reduce_1d_nb function

groupby_reduce_1d_nb(
    arr,
    group_map,
    reduce_func_nb,
    *args
)

Provide group-by reduce calculations.

reduce_func_nb must accept the array and *args. Must return a single value.


groupby_reduce_meta_nb function

groupby_reduce_meta_nb(
    n_cols,
    group_map,
    reduce_func_nb,
    *args
)

2-dim version of groupby_reduce_1d_meta_nb().


groupby_reduce_nb function

groupby_reduce_nb(
    arr,
    group_map,
    reduce_func_nb,
    *args
)

2-dim version of groupby_reduce_1d_nb().


groupby_transform_meta_nb function

groupby_transform_meta_nb(
    target_shape,
    group_map,
    transform_func_nb,
    *args
)

Meta version of groupby_transform_nb().

transform_func_nb must accept the array of indices in the group, the group index, and *args. Must return a scalar or an array that broadcasts against the group's shape.


groupby_transform_nb function

groupby_transform_nb(
    arr,
    group_map,
    transform_func_nb,
    *args
)

Provide group-by transform calculations.

transform_func_nb must accept the 2-dim array of the group and *args. Must return a scalar or an array that broadcasts against the group array's shape.


last_index_reduce_nb function

last_index_reduce_nb(
    arr
)

Get index of last non-NA element.


last_reduce_nb function

last_reduce_nb(
    arr
)

Get last non-NA element.


map_1d_meta_nb function

map_1d_meta_nb(
    n,
    col,
    map_func_nb,
    *args
)

Meta version of map_1d_nb().

map_func_nb must accept the row index, the column index, and *args. Must return a single value.


map_1d_nb function

map_1d_nb(
    arr,
    map_func_nb,
    *args
)

Map elements element-wise using map_func_nb.

map_func_nb must accept the element and *args. Must return a single value.


map_meta_nb function

map_meta_nb(
    target_shape,
    map_func_nb,
    *args
)

2-dim version of map_1d_meta_nb().


map_nb function

map_nb(
    arr,
    map_func_nb,
    *args
)

2-dim version of map_1d_nb().


max_reduce_nb function

max_reduce_nb(
    arr
)

Get max. Ignores NaN.


mean_reduce_nb function

mean_reduce_nb(
    arr
)

Get mean. Ignores NaN.


median_reduce_nb function

median_reduce_nb(
    arr
)

Get median. Ignores NaN.


min_reduce_nb function

min_reduce_nb(
    arr
)

Get min. Ignores NaN.


nonzero_prod_reduce_nb function

nonzero_prod_reduce_nb(
    arr
)

Get product. Ignores zero and NaN. Default value is zero.


nth_index_reduce_nb function

nth_index_reduce_nb(
    arr,
    n
)

Get index of n-th element including NA elements.


nth_reduce_nb function

nth_reduce_nb(
    arr,
    n
)

Get n-th element.


prod_reduce_nb function

prod_reduce_nb(
    arr
)

Get product. Ignores NaN.


proximity_reduce_meta_nb function

proximity_reduce_meta_nb(
    target_shape,
    window,
    reduce_func_nb,
    *args
)

Meta version of proximity_reduce_nb().

reduce_func_nb must accept the start row index, the end row index, the start column index, the end column index, and *args. Must return a single value.


proximity_reduce_nb function

proximity_reduce_nb(
    arr,
    window,
    reduce_func_nb,
    *args
)

Flatten window surrounding rows and columns and reduce them into a single value using reduce_func_nb.

reduce_func_nb must accept the array and *args. Must return a single value.


reduce_flat_grouped_nb function

reduce_flat_grouped_nb(
    arr,
    group_map,
    in_c_order,
    reduce_func_nb,
    *args
)

Same as reduce_grouped_nb() but passes flattened array.


reduce_flat_grouped_to_array_nb function

reduce_flat_grouped_to_array_nb(
    arr,
    group_map,
    in_c_order,
    reduce_func_nb,
    *args
)

Same as reduce_grouped_to_array_nb() but passes flattened array.


reduce_grouped_meta_nb function

reduce_grouped_meta_nb(
    group_map,
    reduce_func_nb,
    *args
)

Meta version of reduce_grouped_nb().

reduce_func_nb must accept the column indices of the group, the group index, and *args. Must return a single value.


reduce_grouped_nb function

reduce_grouped_nb(
    arr,
    group_map,
    reduce_func_nb,
    *args
)

Reduce each group of columns into a single value using reduce_func_nb.

reduce_func_nb must accept the 2-dim array and *args. Must return a single value.


reduce_grouped_to_array_meta_nb function

reduce_grouped_to_array_meta_nb(
    group_map,
    reduce_func_nb,
    *args
)

Same as reduce_grouped_meta_nb() but reduce_func_nb must return an array.


reduce_grouped_to_array_nb function

reduce_grouped_to_array_nb(
    arr,
    group_map,
    reduce_func_nb,
    *args
)

Same as reduce_grouped_nb() but reduce_func_nb must return an array.


reduce_index_ranges_1d_meta_nb function

reduce_index_ranges_1d_meta_nb(
    col,
    range_starts,
    range_ends,
    reduce_func_nb,
    *args
)

Meta version of reduce_index_ranges_1d_nb().

reduce_func_nb must accept the start row index, the end row index, the column, and *args. Must return a single value.


reduce_index_ranges_1d_nb function

reduce_index_ranges_1d_nb(
    arr,
    range_starts,
    range_ends,
    reduce_func_nb,
    *args
)

Reduce each index range.

reduce_func_nb must accept the array and *args. Must return a single value.


reduce_index_ranges_meta_nb function

reduce_index_ranges_meta_nb(
    n_cols,
    range_starts,
    range_ends,
    reduce_func_nb,
    *args
)

2-dim version of reduce_index_ranges_1d_meta_nb().


reduce_index_ranges_nb function

reduce_index_ranges_nb(
    arr,
    range_starts,
    range_ends,
    reduce_func_nb,
    *args
)

2-dim version of reduce_index_ranges_1d_nb().


reduce_meta_nb function

reduce_meta_nb(
    n_cols,
    reduce_func_nb,
    *args
)

Meta version of reduce_nb().

reduce_func_nb must accept the column index and *args. Must return a single value.


reduce_nb function

reduce_nb(
    arr,
    reduce_func_nb,
    *args
)

Reduce each column into a single value using reduce_func_nb.

reduce_func_nb must accept the array and *args. Must return a single value.


reduce_to_array_meta_nb function

reduce_to_array_meta_nb(
    n_cols,
    reduce_func_nb,
    *args
)

Same as reduce_meta_nb() but reduce_func_nb must return an array.


reduce_to_array_nb function

reduce_to_array_nb(
    arr,
    reduce_func_nb,
    *args
)

Same as reduce_nb() but reduce_func_nb must return an array.


rolling_freq_reduce_1d_meta_nb function

rolling_freq_reduce_1d_meta_nb(
    col,
    index,
    freq,
    reduce_func_nb,
    *args
)

Meta version of rolling_freq_reduce_1d_nb().

reduce_func_nb must accept the start row index, the end row index, the column, and *args. Must return a single value.


rolling_freq_reduce_1d_nb function

rolling_freq_reduce_1d_nb(
    index,
    arr,
    freq,
    reduce_func_nb,
    *args
)

Provide rolling, frequency-based window calculations.

reduce_func_nb must accept the array and *args. Must return a single value.


rolling_freq_reduce_meta_nb function

rolling_freq_reduce_meta_nb(
    n_cols,
    index,
    freq,
    reduce_func_nb,
    *args
)

2-dim version of rolling_freq_reduce_1d_meta_nb().


rolling_freq_reduce_nb function

rolling_freq_reduce_nb(
    index,
    arr,
    freq,
    reduce_func_nb,
    *args
)

2-dim version of rolling_reduce_1d_nb().


rolling_reduce_1d_meta_nb function

rolling_reduce_1d_meta_nb(
    n,
    col,
    window,
    minp,
    reduce_func_nb,
    *args
)

Meta version of rolling_reduce_1d_nb().

reduce_func_nb must accept the start row index, the end row index, the column, and *args. Must return a single value.


rolling_reduce_1d_nb function

rolling_reduce_1d_nb(
    arr,
    window,
    minp,
    reduce_func_nb,
    *args
)

Provide rolling window calculations.

reduce_func_nb must accept the array and *args. Must return a single value.


rolling_reduce_meta_nb function

rolling_reduce_meta_nb(
    target_shape,
    window,
    minp,
    reduce_func_nb,
    *args
)

2-dim version of rolling_reduce_1d_meta_nb().


rolling_reduce_nb function

rolling_reduce_nb(
    arr,
    window,
    minp,
    reduce_func_nb,
    *args
)

2-dim version of rolling_reduce_1d_nb().


rolling_reduce_two_1d_nb function

rolling_reduce_two_1d_nb(
    arr1,
    arr2,
    window,
    minp,
    reduce_func_nb,
    *args
)

Provide rolling window calculations for two arrays.

reduce_func_nb must accept two arrays and *args. Must return a single value.


rolling_reduce_two_nb function

rolling_reduce_two_nb(
    arr1,
    arr2,
    window,
    minp,
    reduce_func_nb,
    *args
)

2-dim version of rolling_reduce_two_1d_nb().


row_apply_meta_nb function

row_apply_meta_nb(
    target_shape,
    apply_func_nb,
    *args
)

Meta version of row_apply_nb() that prepends the row index to the arguments of apply_func_nb.


row_apply_nb function

row_apply_nb(
    arr,
    apply_func_nb,
    *args
)

apply_nb() but applied on rows rather than columns.


squeeze_grouped_meta_nb function

squeeze_grouped_meta_nb(
    n_rows,
    group_map,
    squeeze_func_nb,
    *args
)

Meta version of squeeze_grouped_nb().

squeeze_func_nb must accept the row index, the column indices of the group, the group index, and *args. Must return a single value.


squeeze_grouped_nb function

squeeze_grouped_nb(
    arr,
    group_map,
    squeeze_func_nb,
    *args
)

Squeeze each group of columns into a single column using squeeze_func_nb.

squeeze_func_nb must accept index the array and *args. Must return a single value.


std_reduce_nb function

std_reduce_nb(
    arr,
    ddof
)

Get std. Ignores NaN.


sum_reduce_nb function

sum_reduce_nb(
    arr
)

Get sum. Ignores NaN.


wmean_range_reduce_meta_nb function

wmean_range_reduce_meta_nb(
    from_i,
    to_i,
    col,
    arr1,
    arr2
)

Get the weighted average.