Kwker

All operations

Every Kwker operation in one list, grouped by task. Each row links to the guide that explains it with examples. The names are the Python ones; other languages use the same names in their own style (for example top_k is TopK in Go and topK in JavaScript). See Languages.

Sorting

You want to Call Guide
Sort an array in place sort Sorting
Get a sorted copy sorted Sorting
Sort every row or column of a matrix sort(a, axis=...) Sorting
Sort on several cores sort(a, threads=...) Large data
Sort strings sort_strings Strings
Sort keys and move values with them sort_kv Keys with values
Sort a file larger than memory sort_file Large data

Finding the top values

You want to Call Guide
The k largest or smallest, with positions top_k Top-k and selection
Only the positions of the k largest or smallest argselect Top-k and selection
The median or any percentile select Top-k and selection
The first k positions sorted partial_sort Top-k and selection
The top k among selected entries top_k_masked Top-k and selection
The top k of every group or segment top_k_by_group, top_k_segments Top-k and selection
A median, quantile or median absolute deviation over a sliding window rolling_median, rolling_quantile, rolling_mad Top-k and selection
A trimmed mean or a weighted quantile trim_mean, weighted_quantile Statistics
Average precision or ROC AUC of a classifier average_precision_score, roc_auc_score Statistics

Order and ranks

You want to Call Guide
The positions that would sort an array argsort Order and ranking
Ranks (average, min, max, dense, ordinal) rank Order and ranking
Ranks between 0 and 1 percent_rank Order and ranking
Sort rows by several columns lexsort Order and ranking
The first k rows by several columns lex_top_k Order and ranking
Reorder records without a copy permute_in_place Order and ranking

Searching sorted data

You want to Call Guide
Where values would go in a sorted array searchsorted Searching
The bucket of every value bucketize Searching
How many values fall in each bucket bucket_counts Searching

Statistics and data helpers

You want to Call Guide
Running totals, lags and ranks within groups group_cumsum, group_shift, group_diff, rank_by_group Statistics
Medians and quantiles of everything so far expanding_median, expanding_quantile Statistics
How far apart two samples are (KS, Wasserstein, energy) cdf_distance Statistics
Discordant pairs (Kendall tau) count_inversions Statistics
Counts in uniform bins histogram Statistics
The latest row at or before each time (as-of join) asof_indices Statistics
Shared or distinct ids per row row_intersect_count, row_unique_count Statistics
Top-p, top-n-sigma, min-p and per-row top-k filters of logits top_p, top_n_sigma, min_p_filter, top_k_filter Statistics
Distinct strings, sorted unique_strings Statistics

Groups, merges and sets

You want to Call Guide
A total (sum, mean, count, ...) per key reduce_by_key Groups, merges and sets
The distinct values, with counts, first positions or the inverse unique Groups, merges and sets
A group number for every row group_codes Groups, merges and sets
Merge sorted arrays kway_merge Groups, merges and sets
Intersection, union, difference intersect1d, union1d, setdiff1d, setxor1d, set_op_sorted Groups, merges and sets
Which values appear in another array isin Groups, merges and sets
Group-by on a pandas / Polars / pyarrow table kwker.frame.group_by DataFrames

Big and distributed data

You want to Call Guide
Cap the scratch memory of a thread set_scratch_limit Large data
Pick boundaries for a distributed sort sample, splitters, splitters_exact Large data
Split data at those boundaries partition_splitters, partition_indices, split_points Large data

Special data

You want to Call
Sort two 4-bit numbers packed per byte (GGML / ONNX layout) sort_int4_packed, argsort_int4_packed, top_k_int4_packed
Combine duplicate entries of a sparse COO matrix coo_coalesce
Convert sparse matrices between COO, CSR and CSC coo_to_csr, coo_to_csc, csr_to_csc, csc_to_csr
Order Apache Arrow arrays in place arrow_argsort, arrow_top_k (DataFrames)
Speed up PyTorch's sorting and selection kernels kwker.torch_ops.install() (PyTorch)

Calls that put values in order, such as sort, top_k, argsort, rank and searchsorted, take the same two order options: descending and nans_first. The full list of arguments is in the Python API reference.