Filter nlargest of Group

Hi there,

is there a Knime way to filter out the top n largest values of a group?
In Python/Pandas I’d use this one here:

df.groupby('GroupCol')['ValCol'].nlargest(2)

Andreas

Hello @ActionAndi

‘Top k Selector’ node can do the task:

You could combine with Group By or Group Loop Start depending on the use case.

BR

5 Likes

Hi @ActionAndi ,
Here’s a test table with alpha labels and random int

If this is the result you want (2 largest values per group)

you could use a workflow like this one
KNIME_temp.knwf (10.4 KB)

4 Likes

@duristef
Ranking by Groups is a good approach indeed.

1 Like

@duristef: This is pretty neat! Thanks a lot!

@gonhaddock: Your Solution is working good as well! Thanks you too!

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.