对数据框按某变量进行分类汇总,然后按分类结果排序,standalone 下的代码
using DataFrames, Query
df = DataFrame(x = ["a", "a", "b", "b", "a", "b", "b", "c", "c"], y = collect(1:9))
df2 = df |>
@groupby(_.x) |>
@map({g = key(_), v = length(_)}) |>
@orderby_descending(_.v) |>
DataFrame
结果为
g v
b 4
a 3
c 2
上述过程如何在 LINQ style 下实现?
谢谢