Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

ajozefiak
Copy link

Addition of an example to the documentation of constructing a data frame from an array of named tuples. As suggested in #1573

@@ -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:
Copy link
Member

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).

@bkamins bkamins mentioned this pull request Jan 15, 2019
31 tasks
@@ -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:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
julia> df = DataFrame([r1, r2])
julia> df = DataFrame([(A = 1, B = "M"),
(A = 2, B = "N")])

Copy link
Member

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?

@bkamins
Copy link
Member

bkamins commented Jul 24, 2019

@ajozefiak I have left some comments. I think this PR is good to merge when they are incorporated. Thank you!

@bkamins bkamins mentioned this pull request Jan 3, 2020
@bkamins
Copy link
Member

bkamins commented Jan 3, 2020

I have opened #2077 instead of this PR.

@bkamins bkamins closed this Jan 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants