Create a new column that has a list of items of a second column, with a condition from a third column

Hi, I have a simple problem: I have a DataFrame that looks like this:

df = DataFrame()

df.sum = [[200,0,1,1,0], [0,0,0], [0,1,1,1,1,0,0]]
df.score= [[1,2,22,25,5], [1,1,2], [1,24,54,89,12,1,2]] = ["1", "2", "3"]

And I want to generate a column that has the values of df.score that coincide with the values that are >+ 1 in the df.sum column. This is my expected result:

df.x1 = [[1,22,25], [], [24,54,89,12]]

Where the second row should be empty, because there are no values greater than 1 in df.sum[1].

This is the code that I’ve been tinkering with (I took it from Change coulumn to row using conditions), but I can’t get my head around on how to modify it so it works:

	dv2 = df.sum;
	for (i, v) in enumerate(dv2)
		for (j,h) in enumerate(v) 
    		if h >= 1
        		df[:,:new_col] .= df.Score[i][j]

The problem with this that it gives me a column that is composed only by the number 12 ([12, 12, 12]) in every row, and that is the last value that is greater than 1 of the last column. I don’t know why this happens, but I know that it has to do with how I the loop is written

Any help is welcome, thanks a lot!

I don’t understand what the actual transformation you are trying to do is, but here is an answer using DataFramesMeta.jl

julia> t = @rtransform df :x1 = begin 
           better_than = :score .> (:sum .+ 1)

julia> @select t :id :x1
3×2 DataFrame
 Row │ id      x1                  
     │ String  Array…              
   1 │ 1       [2, 22, 25, 5]
   2 │ 2       [2]
   3 │ 3       [24, 54, 89, 12, 2]

EDIT: you want

julia> t = @rtransform df :x1 = begin 
           better_than = :sum .>= 1