Skip to content

Conversation

@texodus
Copy link
Member

@texodus texodus commented May 22, 2025

This PR adds two new aggregate types, min by and max by, as well as UI support and tests. These aggregates take two columns rather than one, similar to the weighted mean aggregate, and will return the value from the first column, which corresponds with the max row from the second. For this dataset:

const data = {
    a: [1, 2, 3, 4, 5, 6, 7, 8],
    b: [0, 1, 0, 1, 0, 1, 0, 1],
    c: ["h", "g", "f", "e", "d", "c", "b", "a"],
};

const config = {
    columns: ["c"],
    aggregates: {
        c: ["max by", "a"],
    },
    group_by: ["b"],
};

we can use the max by aggregate to select string from column "c" which corresponds to the maximum "a" for every group "b".

@texodus texodus added the enhancement Feature requests or improvements label May 22, 2025
texodus added 2 commits May 22, 2025 00:22
Signed-off-by: Andrew Stein <steinlink@gmail.com>
Signed-off-by: Andrew Stein <steinlink@gmail.com>
@texodus texodus merged commit 425b6eb into master May 22, 2025
14 checks passed
@texodus texodus deleted the max-min-by branch May 22, 2025 16:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature requests or improvements

Development

Successfully merging this pull request may close these issues.

2 participants