Suppose I have a DataFrame df and GroupDataFrame
df = DataFrame(a=[1,1,2,2], b =[3,3,4,4])
dfg = groupby(df,:a)
further suppose I have a function fun1
that takes a vector x and multiple arguments y, z.
function fun1(x,y,z)
for i = eachindex(x)
x[i] = (x[i]+y)^z
end
end
Is there a way to pass the fun1
transformation via the
source_column => transformation => target_column_name
format? I tried using an anonymous function in parenthesis but it yielded
transform!(dfg, :a => (x -> fun1(x,1,2)) => :c)
4Γ3 DataFrame
Row β a b c
β Int64 Int64 Nothing
ββββββΌβββββββββββββββββββββββ
1 β 4 3
2 β 4 3
3 β 9 4
4 β 9 4
as opposed to the desired result of
Row β a b c
β Int64 Int64 Nothing
ββββββΌβββββββββββββββββββββββ
1 β 1 3 4
2 β 1 3 4
3 β 2 4 9
4 β 2 4 9