-
Notifications
You must be signed in to change notification settings - Fork 368
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
Construction from a named tuple documentation #1580
Conversation
@@ -124,37 +124,63 @@ It is also possible to fill a `DataFrame` row by row. Let us construct an empty | |||
julia> df = DataFrame(A = Int[], B = String[]) | |||
0×2 DataFrame | |||
``` | |||
Additionally, a `DataFrame` object can be constructed from an array of named tuples, where each tuple of the array corresponds to a row of the new data frame. The order and types of the elements in each of the named tuples specify the order of the columns and their types: |
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.
I guess it should be
vector of named tuples, where each named tuple in the vector"
(not native speaker though).
@@ -124,37 +124,63 @@ It is also possible to fill a `DataFrame` row by row. Let us construct an empty | |||
julia> df = DataFrame(A = Int[], B = String[]) | |||
0×2 DataFrame | |||
``` | |||
Additionally, a `DataFrame` object can be constructed from an array of named tuples, where each tuple of the array corresponds to a row of the new data frame. The order and types of the elements in each of the named tuples specify the order of the columns and their types: |
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.
Additionally, a `DataFrame` object can be constructed from an array of named tuples, where each tuple of the array corresponds to a row of the new data frame. The order and types of the elements in each of the named tuples specify the order of the columns and their types: | |
Additionally, a `DataFrame` object can be constructed from any object that supports Tables.jl interface, for example a vector of `NamedTuple`s: |
julia> r2 = (A = 2, B = "N") | ||
(A = 2, B = "N") | ||
|
||
julia> df = DataFrame([r1, r2]) |
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.
julia> df = DataFrame([r1, r2]) | |
julia> df = DataFrame([(A = 1, B = "M"), | |
(A = 2, B = "N")]) |
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.
I think we do not need to show creation of r1
and r2
explicitly. Can you also please remove the respective lines above?
@ajozefiak I have left some comments. I think this PR is good to merge when they are incorporated. Thank you! |
I have opened #2077 instead of this PR. |
Addition of an example to the documentation of constructing a data frame from an array of named tuples. As suggested in #1573