Hi,
Probably a simple question, but with DataFrames.jl I’m having trouble returning the data frame grouped by the first column, the sorted by the last column. Here’s a MWE
using DataFrames
A = rand(5,5)
A[:,1] = [1, 1, 2, 2, 4]
df = DataFrame(A)
df2 = by(df, :x1, df -> minimum(df.x2))
Output is:
julia> df
5×5 DataFrame
│ Row │ x1 │ x2 │ x3 │ x4 │ x5 │
│ │ Float64 │ Float64 │ Float64 │ Float64 │ Float64 │
├─────┼─────────┼──────────┼───────────┼──────────┼──────────┤
│ 1 │ 1.0 │ 0.684006 │ 0.27617 │ 0.453495 │ 0.701109 │
│ 2 │ 1.0 │ 0.282817 │ 0.94968 │ 0.531294 │ 0.262201 │
│ 3 │ 2.0 │ 0.802795 │ 0.0950535 │ 0.538556 │ 0.155517 │
│ 4 │ 2.0 │ 0.986956 │ 0.609984 │ 0.633382 │ 0.169541 │
│ 5 │ 4.0 │ 0.975459 │ 0.876686 │ 0.105175 │ 0.221114 │
julia> df2
3×2 DataFrame
│ Row │ x1 │ x1_1 │
│ │ Float64 │ Float64 │
├─────┼─────────┼──────────┤
│ 1 │ 1.0 │ 0.282817 │
│ 2 │ 2.0 │ 0.802795 │
│ 3 │ 4.0 │ 0.975459 │
So in the above, df2 is a sorted with just the first and last column, but I’d like to return all columns. Anyone know how to go about doing that?
Thanks!