Hey there,
I recently watched @davidanthoff’s Queryverse tutorial and am giving Query.jl a go. I like the new pipe-able syntax as I’m a heavy user of dplyr. I see the @map
macro would be similar to the select
and mutate
functions in dplyr. I was wondering though how to return all of the columns of a table after the @map
macro? It looks like the macro only returns the columns I’ve selected or calculated. Looking at the Linq syntax in the documentation it looks like the @let
macro is similar to what I’m looking for so I was curious how to do it with the new syntax.
2 Likes
There is currently no good story for that in Query.jl: you can either pass on all columns with simply _
, but of course that is kind of pointless If you want to just manipulate say one column, you have to explicitly also select all the columns that you want to return, say as @map({_.colA, _.colB, colC = _.colC*2, _.colD})
etc.
I have a complete design mapped out how to do this better, so that we can have more dplyr like functions for these situations. But, it requires julia 0.7 and the native named tuples, so that is why I haven’t added it so far. It will be one of the first new features I’ll add when I port things over to julia 0.7 (I’ve started with that recently).
3 Likes
Sorry to revive this old topic-- if I understand correctly, this was solved with @mutate
. But is there a way to do that for joins? i.e. something like
x = df1 |> @join(df2, _.a, _.c, {_.a, keys(__)}) |> DataFrame
Yes, you can now use splatting syntax inside {}
, so you can just write the join part as
@join(df2, _.a, _.c, {_..., __...})
That will take all the columns from the first and the second table and combine them.
2 Likes