-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Tables.jl interface (#78)
* Add support for Tables interface.
- Loading branch information
Showing
10 changed files
with
69 additions
and
17 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 |
---|---|---|
|
@@ -2,3 +2,4 @@ src/scratch.jl | |
*.png | ||
.DS_Store | ||
.vscode | ||
Manifest.toml |
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
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 |
---|---|---|
|
@@ -196,7 +196,8 @@ read_hdf, | |
HDFStore, | ||
info, | ||
put, | ||
walk | ||
walk, | ||
equals | ||
|
||
if !isdefined(Base, :drop) | ||
export drop | ||
|
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using Tables | ||
|
||
function _construct_pandas_from_tables(source) | ||
if(!Tables.istable(source)) | ||
return nothing | ||
end | ||
source_columns = Tables.columns(source) | ||
source_as_dict = Dict(column => Tables.getcolumn(source_columns, column) for column in Tables.columnnames(source_columns)) | ||
return invoke(DataFrame, Tuple{Vararg{Any}}, source_as_dict) | ||
end |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[deps] | ||
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b" | ||
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" | ||
IteratorInterfaceExtensions = "82899510-4779-5014-852e-03e436cf321d" | ||
TableTraits = "3783bdb8-4a98-5b6b-af9a-565f29a5fe9c" | ||
DataValues = "e7dc6d0d-1eca-5fa6-8ad6-5aecde8b7ea5" | ||
Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" | ||
|
||
[compat] | ||
IteratorInterfaceExtensions = "^0.1.1, ^1" | ||
TableTraits = "^0.4, ^1" | ||
DataValues = "0.4.4" | ||
Tables = "1" |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Pandas | ||
using Test | ||
using CSV | ||
using Tables | ||
|
||
@testset "tables" begin | ||
|
||
file = IOBuffer("""Temp;Val;Gr | ||
20;7863;1 | ||
100;7834;1 | ||
200;7803;1""") | ||
csv = CSV.File(file, types=[Float64, Float64, Int]) | ||
df = DataFrame(csv) | ||
expected_df = DataFrame(:Val=>[7863.0, 7834.0, 7803.0], :Temp=>[20.0, 100.0, 200.0], :Gr=>[1,1,1]) | ||
@test equals(df, expected_df) | ||
|
||
@test Tables.istable(df) | ||
df_cols = Tables.columns(df) | ||
@test Tables.getcolumn(df_cols, :Gr) == [1, 1, 1] | ||
@test Tables.getcolumn(df_cols, :Val) == [7863.0, 7834.0, 7803.0] | ||
@test Tables.getcolumn(df_cols, :Temp) == [20.0, 100.0, 200.0] | ||
end |
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