Skip to content

Commit 3325c30

Browse files
authored
Add DataFrames to the example (#11)
1 parent 7ea0d55 commit 3325c30

4 files changed

Lines changed: 20 additions & 5 deletions

File tree

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,18 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
88
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
99

1010
[compat]
11+
DataFrames = "0.21"
1112
DocStringExtensions = "0.8"
1213
PrettyPrint = "0.1"
1314
StructArrays = "0.4"
1415
julia = "1.1"
1516

1617
[extras]
18+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
1719
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
1820
PrettyPrint = "8162dcfd-2161-5ef2-ae6c-7681170c5f98"
1921
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
2022
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
2123

2224
[targets]
23-
test = ["Documenter", "PrettyPrint", "StructArrays", "Test"]
25+
test = ["DataFrames", "Documenter", "PrettyPrint", "StructArrays", "Test"]

docs/Project.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
[deps]
2+
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
23
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
34
OMOPCommonDataModel = "ba65db9e-6590-4054-ab8a-101ed9124986"
45
PrettyPrint = "8162dcfd-2161-5ef2-ae6c-7681170c5f98"
56
StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a"
67

78
[compat]
9+
DataFrames = "0.21"
810
PrettyPrint = "0.1"
911
StructArrays = "0.4"

docs/src/examples.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ CurrentModule = OMOPCommonDataModel
77
```jldoctest
88
julia> using OMOPCommonDataModel
99
10-
julia> using PrettyPrint
11-
12-
julia> using StructArrays
10+
julia> using DataFrames, PrettyPrint, StructArrays
1311
1412
julia> jack = Person(person_id = 1, gender_concept_id = 12, year_of_birth = 1900, race_concept_id = 21, ethnicity_concept_id = 31, gender_source_concept_id = 42, race_source_concept_id = 51, ethnicity_source_concept_id = 61)
1513
Person(1, 12, 1900, missing, missing, missing, missing, 21, 31, missing, missing, missing, missing, missing, 42, missing, 51, missing, 61)
@@ -39,6 +37,7 @@ Person(
3937
ethnicity_source_value=missing,
4038
ethnicity_source_concept_id=61,
4139
)
40+
4241
julia> pprint(jill)
4342
Person(
4443
person_id=2,
@@ -61,8 +60,19 @@ Person(
6160
ethnicity_source_value=missing,
6261
ethnicity_source_concept_id=62,
6362
)
64-
julia> person_table = StructArray([jack, jill])
63+
64+
julia> person_table = StructArray(Person[jack, jill])
6565
2-element StructArray(::Vector{Int64}, ::Vector{Int64}, ::Vector{Int64}, ::Vector{Union{Missing, Int64}}, ::Vector{Union{Missing, Int64}}, ::Vector{Union{Missing, Dates.DateTime}}, ::Vector{Union{Missing, Dates.DateTime}}, ::Vector{Int64}, ::Vector{Int64}, ::Vector{Union{Missing, Int64}}, ::Vector{Union{Missing, Int64}}, ::Vector{Union{Missing, Int64}}, ::Vector{Union{Missing, String}}, ::Vector{Union{Missing, String}}, ::Vector{Int64}, ::Vector{Union{Missing, String}}, ::Vector{Int64}, ::Vector{Union{Missing, String}}, ::Vector{Int64}) with eltype Person:
6666
Person(1, 12, 1900, missing, missing, missing, missing, 21, 31, missing, missing, missing, missing, missing, 42, missing, 51, missing, 61)
6767
Person(2, 11, 1900, 1, 1, missing, missing, 22, 32, missing, missing, missing, missing, missing, 41, missing, 52, missing, 62)
68+
69+
julia> person_table_df = DataFrame(person_table);
70+
71+
julia> @show person_table_df;
72+
person_table_df = 2×19 DataFrame
73+
│ Row │ person_id │ gender_concept_id │ year_of_birth │ month_of_birth │ day_of_birth │ birth_datetime │ death_datetime │ race_concept_id │ ethnicity_concept_id │ location_id │ provider_id │ care_site_id │ person_source_value │ gender_source_value │ gender_source_concept_id │ race_source_value │ race_source_concept_id │ ethnicity_source_value │ ethnicity_source_concept_id │
74+
│ │ Int64 │ Int64 │ Int64 │ Int64? │ Int64? │ DateTime…? │ DateTime…? │ Int64 │ Int64 │ Int64? │ Int64? │ Int64? │ String? │ String? │ Int64 │ String? │ Int64 │ Union{Missing, String} │ Int64 │
75+
├─────┼───────────┼───────────────────┼───────────────┼────────────────┼──────────────┼────────────────┼────────────────┼─────────────────┼──────────────────────┼─────────────┼─────────────┼──────────────┼─────────────────────┼─────────────────────┼──────────────────────────┼───────────────────┼────────────────────────┼────────────────────────┼─────────────────────────────┤
76+
│ 1 │ 1 │ 12 │ 1900 │ missing │ missing │ missing │ missing │ 21 │ 31 │ missing │ missing │ missing │ missing │ missing │ 42 │ missing │ 51 │ missing │ 61 │
77+
│ 2 │ 2 │ 11 │ 1900 │ 1 │ 1 │ missing │ missing │ 22 │ 32 │ missing │ missing │ missing │ missing │ missing │ 41 │ missing │ 52 │ missing │ 62 │
6878
```

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using OMOPCommonDataModel
22

3+
using DataFrames
34
using Documenter
45
using PrettyPrint
56
using StructArrays

0 commit comments

Comments
 (0)