diff --git a/Project.toml b/Project.toml index 9894b75..e5927dd 100644 --- a/Project.toml +++ b/Project.toml @@ -13,6 +13,8 @@ Sobol = "ed01d8cd-4d21-5b2a-85b4-cc3bdc58bad4" StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91" StatsFuns = "4c63d2b9-4356-54db-8cca-17b64c39e42c" StructArrays = "09ab397b-f2b6-538f-b94a-2f83cf4a842a" +Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" +TypedTables = "9d95f2ec-7b3d-5a63-8d20-e2491e220bb9" [compat] ArraysOfArrays = "0.5" @@ -23,6 +25,8 @@ NestedTuples = "0.3" StatsBase = "0.33" StatsFuns = "1" StructArrays = "0.5, 0.6" +Tables = "1" +TypedTables = "1" julia = "1.6" [extras] diff --git a/src/TupleVectors.jl b/src/TupleVectors.jl index b585858..74e69d5 100644 --- a/src/TupleVectors.jl +++ b/src/TupleVectors.jl @@ -1,5 +1,8 @@ module TupleVectors +import Tables +import TypedTables + include("tuplevector.jl") include("summarize.jl") include("chainvec.jl") diff --git a/src/tuplevector.jl b/src/tuplevector.jl index 5eb2e66..8636f3c 100644 --- a/src/tuplevector.jl +++ b/src/tuplevector.jl @@ -157,3 +157,15 @@ end function Base.resize!(tv::TupleVector, n::Int) rmap(x -> resize!(x, n), unwrap(tv)) end + +TypedTables.columnnames(::TupleVector{NamedTuple{N,T}}) where {N,T} = N + +Tables.istable(::Type{<:TupleVector}) = true +Tables.rowaccess(::Type{<:TupleVector}) = true +Tables.columnaccess(::Type{<:TupleVector}) = true + +Tables.schema(tv::TupleVector{NamedTuple{N,T}}) where {N,T} = Tables.Schema(N,T) + +Tables.columns(tv::TupleVector) = unwrap(tv) + +Tables.rows(tv::TupleVector) = tv \ No newline at end of file