Created
August 20, 2021 02:47
-
-
Save vochicong/00387f91aa128deecada81827d3ba7ad to your computer and use it in GitHub Desktop.
groupby-dataframes.jl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df = DataFrame(g=[1,2,3,1,2,1], e=[10,20,30,11,21,12]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df.groupby("g").agg(list) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| df_grouped_elements = @chain df begin | |
| @groupby(:g) | |
| @combine(:e = [collect(:e)]) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using DataFrames, DataFrameMacros, Chain |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment