-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from davidanthoff/datatable-dataframe
Add support for DataTables and DataFrames
- Loading branch information
Showing
4 changed files
with
130 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
julia 0.5 | ||
DataArrays | ||
NullableArrays | ||
DataFrames | ||
DataTables | ||
BinDeps | ||
@windows WinRPM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,75 @@ | ||
using NullableArrays, Base.Test | ||
using DataArrays, NullableArrays, DataTables, DataFrames, Base.Test | ||
|
||
dtafile = joinpath(dirname(@__FILE__), "types.dta") | ||
|
||
# Test default return container type | ||
|
||
df = read_dta(dtafile) | ||
@test typeof(df[:, :vfloat]) == NullableVector{Float32} | ||
@test typeof(df[:, :vdouble]) == NullableVector{Float64} | ||
@test typeof(df[:, :vlong]) == NullableVector{Int32} | ||
@test typeof(df[:, :vint]) == NullableVector{Int16} | ||
@test typeof(df[:, :vbyte]) == NullableVector{Int8} | ||
@test typeof(df[:, :vstring]) == NullableVector{String} | ||
|
||
@test get(df[2, :vfloat]) == 7 | ||
@test get(df[2, :vdouble]) == 7 | ||
@test get(df[2, :vlong]) == 7 | ||
@test get(df[2, :vint]) == 7 | ||
@test get(df[2, :vbyte]) == 7 | ||
@test get(df[2, :vstring]) == "7" | ||
|
||
@test isnull(df[3, :vfloat]) | ||
@test isnull(df[3, :vdouble]) | ||
@test isnull(df[3, :vlong]) | ||
@test isnull(df[3, :vint]) | ||
@test isnull(df[3, :vbyte]) | ||
@test get(df[3, :vstring]) == "" | ||
@test typeof(df[:, :vfloat]) == DataVector{Float32} | ||
@test typeof(df[:, :vdouble]) == DataVector{Float64} | ||
@test typeof(df[:, :vlong]) == DataVector{Int32} | ||
@test typeof(df[:, :vint]) == DataVector{Int16} | ||
@test typeof(df[:, :vbyte]) == DataVector{Int8} | ||
@test typeof(df[:, :vstring]) == DataVector{String} | ||
|
||
@test df[2, :vfloat] == 7 | ||
@test df[2, :vdouble] == 7 | ||
@test df[2, :vlong] == 7 | ||
@test df[2, :vint] == 7 | ||
@test df[2, :vbyte] == 7 | ||
@test df[2, :vstring] == "7" | ||
|
||
@test isna(df[3, :vfloat]) | ||
@test isna(df[3, :vdouble]) | ||
@test isna(df[3, :vlong]) | ||
@test isna(df[3, :vint]) | ||
@test isna(df[3, :vbyte]) | ||
@test df[3, :vstring] == "" | ||
|
||
# Test explicit DataFrame return container type | ||
|
||
df = read_dta(DataFrame, dtafile) | ||
@test typeof(df[:, :vfloat]) == DataVector{Float32} | ||
@test typeof(df[:, :vdouble]) == DataVector{Float64} | ||
@test typeof(df[:, :vlong]) == DataVector{Int32} | ||
@test typeof(df[:, :vint]) == DataVector{Int16} | ||
@test typeof(df[:, :vbyte]) == DataVector{Int8} | ||
@test typeof(df[:, :vstring]) == DataVector{String} | ||
|
||
@test df[2, :vfloat] == 7 | ||
@test df[2, :vdouble] == 7 | ||
@test df[2, :vlong] == 7 | ||
@test df[2, :vint] == 7 | ||
@test df[2, :vbyte] == 7 | ||
@test df[2, :vstring] == "7" | ||
|
||
@test isna(df[3, :vfloat]) | ||
@test isna(df[3, :vdouble]) | ||
@test isna(df[3, :vlong]) | ||
@test isna(df[3, :vint]) | ||
@test isna(df[3, :vbyte]) | ||
@test df[3, :vstring] == "" | ||
|
||
# Test explicit DataTable return container type | ||
|
||
dt = read_dta(DataTable, dtafile) | ||
@test typeof(dt[:, :vfloat]) == NullableVector{Float32} | ||
@test typeof(dt[:, :vdouble]) == NullableVector{Float64} | ||
@test typeof(dt[:, :vlong]) == NullableVector{Int32} | ||
@test typeof(dt[:, :vint]) == NullableVector{Int16} | ||
@test typeof(dt[:, :vbyte]) == NullableVector{Int8} | ||
@test typeof(dt[:, :vstring]) == NullableVector{String} | ||
|
||
@test get(dt[2, :vfloat]) == 7 | ||
@test get(dt[2, :vdouble]) == 7 | ||
@test get(dt[2, :vlong]) == 7 | ||
@test get(dt[2, :vint]) == 7 | ||
@test get(dt[2, :vbyte]) == 7 | ||
@test get(dt[2, :vstring]) == "7" | ||
|
||
@test isnull(dt[3, :vfloat]) | ||
@test isnull(dt[3, :vdouble]) | ||
@test isnull(dt[3, :vlong]) | ||
@test isnull(dt[3, :vint]) | ||
@test isnull(dt[3, :vbyte]) | ||
@test get(dt[3, :vstring]) == "" |