-
Notifications
You must be signed in to change notification settings - Fork 56
Add Usage and Alternatives sections to README #421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,43 @@ or via the `Pkg` REPL mode (enter by typing `]` at the REPL console) | |||||
| ] add DataFramesMeta | ||||||
| ``` | ||||||
|
|
||||||
| # Usage | ||||||
|
|
||||||
| Instead of using DataFrames.jl [manipulation functions](https://dataframes.juliadata.org/stable/man/basics/#Manipulation-Functions) directly, | ||||||
| which use operation pairs to define data frame manipulations, | ||||||
| DataFramesMeta.jl offers macro alternatives to each manipulation function, | ||||||
| which convert a more readable syntax into the appropriate DataFrames.jl function calls. | ||||||
| This syntax simplification is demonstrated with two simple examples below. | ||||||
|
|
||||||
| Define a data frame. | ||||||
|
|
||||||
| ```julia | ||||||
| # Importing DataFramesMeta also implicitly imports DataFrames | ||||||
| using DataFramesMeta | ||||||
| df = DataFrame(a = [1, 2], b = [3, 4]) | ||||||
| ``` | ||||||
|
|
||||||
| Add columns `a` and `b` together and store the result in a new column `c`. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The column's name is |
||||||
|
|
||||||
| ```julia | ||||||
| # With DataFrames | ||||||
| transform(df, [:a, :b] => ((x, y) -> x + y) => :c) | ||||||
|
|
||||||
| # With DataFramesMeta | ||||||
| @transform(df, :c = :a + :b) | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above. |
||||||
| ``` | ||||||
|
|
||||||
| Show only the data frame rows where column `a` is equal to `2`. | ||||||
| (DataFramesMeta.jl offers rowwise 'r' versions of each manipulation macro as well for convenience.) | ||||||
|
|
||||||
| ```julia | ||||||
| # With DataFrames | ||||||
| subset(df, :a => ByRow(==(2))) | ||||||
|
|
||||||
| # With DataFramesMeta | ||||||
| @rsubset(df, :a == 2) | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove parentheses? So it looks cleaner.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't personally like the whitespace-dependent syntax, but your call. I am using the same examples from https://juliadata.org/DataFramesMeta.jl/dev/#Introduction which already have parentheses, so I'd change both or neither. |
||||||
| ``` | ||||||
|
|
||||||
| # Documentation | ||||||
|
|
||||||
| * [Stable](https://JuliaData.github.io/DataFramesMeta.jl/stable) | ||||||
|
|
@@ -37,3 +74,7 @@ Pull requests are welcome. Pull requests should include updated tests. If | |||||
| functionality is changed, docstrings should be added or updated. Generally, | ||||||
| follow the guidelines in | ||||||
| [DataFrames](https://github.com/JuliaData/DataFrames.jl/blob/master/CONTRIBUTING.md). | ||||||
|
|
||||||
| # Alternatives | ||||||
|
|
||||||
| Other high-level data frame manipulation packages are described briefly [here](https://dataframes.juliadata.org/stable/man/querying_frameworks/). | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add something how its similar to R's dplyr?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That doesn't mean anything to me, but you can include a statement like that if you wish.