nb module¶
Numba-compiled functions for records and mapped arrays.
Provides an arsenal of Numba-compiled functions for records and mapped arrays. These only accept NumPy arrays and other Numba-compatible types.
Note
All functions passed as argument must be Numba-compiled.
Records must retain the order they were created in.
ol_ignore_unstack_mapped_nb function¶
ol_repeat_unstack_mapped_nb function¶
ol_unstack_mapped_nb function¶
apply_meta_nb function¶
Meta version of apply_nb().
apply_func_nb must accept the indices, the column index, and *args. Must return an array.
apply_nb function¶
Apply function on mapped array or records per column.
Returns the same shape as arr.
apply_func_nb must accept the values of the column and *args. Must return an array.
bottom_n_mapped_nb function¶
Returns the mask of the bottom N mapped elements.
col_lens_nb function¶
Get column lengths from sorted column array.
Note
Requires col_arr to be in ascending order. This can be done by sorting.
col_map_nb function¶
Build a map between columns and value indices.
Returns an array with indices segmented by column and an array with column lengths.
Works well for unsorted column arrays.
first_n_nb function¶
Returns the mask of the first N elements.
generate_ids_nb function¶
Generate the monotonically increasing id array based on the column index array.
ignore_unstack_mapped_nb function¶
Unstack mapped array by ignoring index data.
is_col_id_sorted_nb function¶
Check whether the column and id arrays are sorted.
is_col_sorted_nb function¶
Check whether the column array is sorted.
last_n_nb function¶
Returns the mask of the last N elements.
map_records_meta_nb function¶
Meta version of map_records_nb().
map_func_nb must accept the record index and *args. Must return a single value.
map_records_nb function¶
Map each record to a single value.
map_func_nb must accept a single record and *args. Must return a single value.
mapped_coverage_map_nb function¶
Get the coverage map of a mapped array.
Each element corresponds to the number of times it was referenced (= duplicates of col_arr and idx_arr). More than one depicts a positional conflict.
mapped_has_conflicts_nb function¶
Check whether mapped array has positional conflicts.
mapped_value_counts_nb function¶
Get value counts globally of an already factorized mapped array.
mapped_value_counts_per_col_nb function¶
Get value counts per column/group of an already factorized mapped array.
mapped_value_counts_per_row_nb function¶
Get value counts per row of an already factorized mapped array.
random_n_nb function¶
Returns the mask of random N elements.
record_col_lens_select_nb function¶
Perform indexing on sorted records using column lengths.
Returns new records.
record_col_map_select_nb function¶
Same as record_col_lens_select_nb() but using column map col_map.
reduce_mapped_meta_nb function¶
Meta version of reduce_mapped_nb().
reduce_func_nb must accept the mapped indices, the column index, and *args. Must return a single value.
reduce_mapped_nb function¶
Reduce mapped array by column to a single value.
Faster than unstack_mapped_nb() and vbt.* used together, and also requires less memory. But does not take advantage of caching.
reduce_func_nb must accept the mapped array and *args. Must return a single value.
reduce_mapped_segments_nb function¶
reduce_mapped_segments_nb(
mapped_arr,
idx_arr,
id_arr,
col_map,
segment_arr,
reduce_func_nb,
*args
)
Reduce each segment of values in mapped array.
Uses the last column, index, and id of each segment for the new value.
reduce_func_nb must accept the values in the segment and *args. Must return a single value.
Note
Groups must come in ascending order per column, and idx_arr and id_arr must come in ascending order per segment of values.
reduce_mapped_to_array_meta_nb function¶
Meta version of reduce_mapped_to_array_nb().
reduce_func_nb is the same as in reduce_mapped_meta_nb().
reduce_mapped_to_array_nb function¶
Reduce mapped array by column to an array.
reduce_func_nb same as for reduce_mapped_nb() but must return an array.
reduce_mapped_to_idx_array_meta_nb function¶
Meta version of reduce_mapped_to_idx_array_nb().
reduce_func_nb is the same as in reduce_mapped_meta_nb().
reduce_mapped_to_idx_array_nb function¶
Reduce mapped array by column to an index array.
Same as reduce_mapped_to_array_nb() except idx_arr must be passed.
Note
Must return integers or raise an exception.
reduce_mapped_to_idx_meta_nb function¶
Meta version of reduce_mapped_to_idx_nb().
reduce_func_nb is the same as in reduce_mapped_meta_nb().
reduce_mapped_to_idx_nb function¶
Reduce mapped array by column to an index.
Same as reduce_mapped_nb() except idx_arr must be passed.
Note
Must return integers or raise an exception.
repeat_unstack_mapped_nb function¶
Unstack mapped array using repeated index data.
top_n_mapped_nb function¶
Returns the mask of the top N mapped elements.
unstack_index_nb function¶
Unstack index using the number of times each element must repeat.
repeat_cnt_arr can be created from the coverage map.
unstack_mapped_nb function¶
Unstack mapped array using index data.