number the column values by categories

Hello Dear All,
I would like to number the column values by their categories as i did in groupno column. All cases should be grouped by the number and story.
8844 + case creation → 1
8844 + dealer reply → 1
8844 + dealer reply (duplicate value) → 2, please see below.

Actually i can do it by python node. But i want to do it without python. Here is the code.
df = input_table_1

df[‘groupno’] = df.groupby([‘number’,‘story’]).cumcount()+1

output_table_1=df

thanks in advance,
Kübra

Hello @kubra_08,

if you want to avoid coding you can use Rank node. Number and story columns are your grouping columns in it and ranking column should be dummy constant column while mode is Ordinal.

Br,
Ivan

3 Likes

Hello @kubra_08
Probably there are few solutions to achieve this result in KNIME. The first one coming to my mind is the Rank node .

However because you have to create counting based on Two Grouping attributes, and rank a third column; you need first to create a copy of your target column $story$ (i.e. with a Sting Manipulation node == $new column$)

join($story$)

Then you can proceed with the rank node with the following configuration:

BR

PS.- @ipazin just anticipated the solution that I was already illustrating

3 Likes

Hi @gonhaddock and @ipazin ,
I used Rank node, as you suggested. It worked perfectly.
Thanks a lot for introducing me to a new and useful node to me.

best regards,
Kübra

3 Likes

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