【发布时间】:2022-10-01 19:39:37
【问题描述】:
ds = Dataset([[1, 1, 1, 2, 2, 2],
[\"foo\", \"bar\", \"monty\", \"foo\", \"bar\", \"monty\"],
[\"a\", \"b\", \"c\", \"d\", \"e\", \"f\"],
[1, 2, 3, 4, 5, 6]], [:g, :key, :foo, :bar])
在 InmemoryDatasets 中,转置函数可以传递列选择器的元组。
transpose(groupby(ds, :g), (:foo, :bar), id = :key)
Result:
g foo bar monty foo_1 bar_1 monty_1
identity identity identity identity identity identity identity
Int64? String? String? String? Int64? Int64? Int64?
1 1 a b c 1 2 3
2 2 d e f 4 5 6
问题:
如何在 DataFrames.jl 中执行此操作?
如何在 R 和 Python 中做到这一点?
标签: python r julia dataframes.jl