Hi, I need to iterate over a large table. In each iteration I get around 10 lines of my table and I need to select (and mark in a new column) one line randomly. Is there a node to do this?
Row value1 value2
Row0 2 4
Row1 4 5
I want to have a new table and get:
Row value1 value2 randomlySelected
Row0 2 4 0
Row1 4 5 1
How can I do this efficiently?
Hi. You can use Shuffle Node and RowFilter nodes to select first ten rows with flag column not setted yet.
An other way to go is to use a Partitioning node, and select random 1 row. See this wf random select row.knwf (34.5 KB)
Hi there @knimerin,
Math Formula should be pretty efficient:
if( floor(rand() * 10) == $$ROWINDEX$$, 1 , 0 )
Are you sure of that?
Rand() is computed for every row so there is no warranty you have choose only one row
you are totally right! Overlook made by me. So to still take similar approach (albeit not one node solution)
floor(rand() * 10) can be calculated inside Math Formula (Variable) node and then fixed value will be used in if() function of Math Formula node. This time should work as it is better tested
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.