How to distribute according to proportionality

With this table:

image

I need to distribute the values, 0, 1, 2, 3 randoomly between those 250 rows filling ‘x’ column acording the proportionality en each column.

So, literaly I need to fill column ‘x’ with 125 registers with 0 value, 25 registers with value 1, 75 registers with value 2 and 25 registers filled with value 3.

How can I accomplish this?

Thanks in advance.

Could you please share your dataset?

1 Like

datset_test_knime_forum.csv (5.2 KB)

Hi @jpages ,

here is a wf that could help:

Basically, what I do is 1) mizxing rows and then 2) assign 125 labels “1”, 25 labels “2”, etc. You can even use variables if you want (I haven’t).
If you are not interested in assigning exactly 125 rows to label “1”, you can make it even simpler and use a random label assigner (probability-based).

Have a nice evening,
Raffaello Barri

2 Likes

Thanks, this is what I need. But, is there a way to reference the first value of a column (for example 125 of column 0, 150 of column 1… in the data sample) in the rule engine node to do it dynamic, instead of a constant value like 125, 150, 225, 250 as yours?

I need it, because this table is in a loop and these values change each chunk.

Have a look at the previous link, I have updated the workflow :slight_smile:

Have a nice evening,
Raffaello Barri

1 Like

Nice! But I have a problem with row rename. When transposed column to row, as I’m using a cuhunk loop, the column name is different every time and then the node “Right rename” doesn’t work.

Any idea to make it dynamic?

Hi @jpages ,

could you send a small wf? It’s difficult to understand the problem otherwise :slight_smile:

Thank you,
Raffaello

I alreaady solved with the help of this post:

Thanks for all.

2 Likes

Glad you found your solution :slight_smile:

RB

1 Like

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