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

[docs] Use OrderedDict in example #8

Merged
merged 1 commit into from
Feb 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ We can also separate these into individual tables.
One, but not the only, way to do this is as follows.

```julia-repl
julia> using DataFrames
julia> using DataFrames, OrderedCollections

julia> tables = Dict{Symbol,DataFrame}();
julia> tables = OrderedDict{Symbol,DataFrame}();

julia> for (name, row) in results
push!(get!(tables, name, DataFrame()), row)
Expand Down Expand Up @@ -231,3 +231,7 @@ julia> tables[:visit]
15 │ 5198d75c-8e1c-4d93-8ae9-ab976c44… Fatigue
16 │ 5198d75c-8e1c-4d93-8ae9-ab976c44… Fatigue
```

Here we use an `OrderedDict` to preserve insertion order. This ensures that tables which are used downstream in the DAG
show up earlier in the dictionary. This allows uploading the tables into e.g. databases which make foreign key checks
smoother, since one simply needs to upload in the order the resulting `OrderedDict` uses.
Loading