I wanted to order a DataFrame by certain mixed order, e.g. i want to order a DataFrame by a_str
in
descending order followed by b_str
in ascending order
Setting up data
using DataFrames, Query
a_str = string.(rand(UInt16, 100))
b_str = string.(rand(UInt16,100))
df = DataFrame(a_str = a_str, b_str = b_str)
DataFrames.jl
@> begin
df
sort!([order(:a_str, rev = true), :b_str])
end
**DataFramesMeta.jl **
Not possible. See: the DataFramesMeta.jl had an outstanding issue from 2017
Query.jl way
#const Q = Query
@> begin
df
@orderby_descending _.a_str
@thenby _.b_str
end
Query.jl has an implementation. But I think Query.jl used to have some significant performance issues.