Hey everyone!
I’m really struggling with a basic concept and was hoping anyone can help me (and that I explain it well enough). Here goes…
I have imported a simple 4x5 dataframe into julia and am trying to apply a function to every row in the dataframe and have the results of every function be readable as an array.
So the thing is though I need to use the elements in every row as part of the function to be able to feed it into the iterator (for-loop).
This is what I’ve got so far and hope it can make it a bit easier to understand:
for i in eachrow(data)
y = (i,2)/(i,3)+(i,1)*(i,5)+(i,4)
i++
return y
end
I hope my problem is understandable and would appreciate any help!
This doesn’t seem to be Julia code - i++ is more of a C idiom?
Assuming you have a function like f(a, b, c, d, e) which takes five inputs, and you have a dataframe with five columns, you can broadcast it as f.(df.col1, df.col2, df.col3, df.col4, df.col5), or even f.(eachcol(df)....):