Is there a way to use Query to just add a new column? In the docs there’s this example:
using Query, DataFrames
df = DataFrame(name=["John", "Sally", "Kirk"], age=[23., 42., 59.], children=[3,5,2])
x = @from i in df begin
@select {i.name, Age=i.age}
@collect DataFrame
end
but I’d like to do something like:
x = @from i in df begin
@select {i, age_in_days=i.age*365}
@collect DataFrame
end
to be equivalent to
x = @from i in df begin
@select {i.name, i.age, i.children, age_in_days=i.age*365}
@collect DataFrame
end
But what I get is:
3×2 DataFrames.DataFrame
│ Row │ i │ new_age │
├─────┼────────────────────────────────────────────┼─────────┤
│ 1 │ (name = "John", age = 23.0, children = 3) │ 8395.0 │
│ 2 │ (name = "Sally", age = 42.0, children = 5) │ 15330.0 │
│ 3 │ (name = "Kirk", age = 59.0, children = 2) │ 21535.0 │
I’ve got a giant table, so @select
ing every column individually would be tedious. I know I can also just make a new vector and add it, but I’m doing a bunch of other filtering operations at the same time, and it would be nice to do them all at once.