To be able to edit code and run cells, you need to run the notebook yourself. Where would you like to run the notebook?

This notebook takes about 20 seconds to run.

In the cloud (experimental)

Binder is a free, open source service that runs scientific notebooks in the cloud! It will take a while, usually 2-7 minutes to get a session.

On your computer

(Recommended if you want to store your changes.)

  1. Copy the notebook URL:
  2. Run Pluto

    (Also see: How to install Julia and Pluto)

  3. Paste URL in the Open box

Frontmatter

If you are publishing this notebook on the web, you can set the parameters below to provide HTML metadata. This is useful for search engines and social media.

Author 1
👀 Reading hidden code
5.8 ms
👀 Reading hidden code
using Tables
31.1 ms
👀 Reading hidden code
begin
struct TestVec{T} <: AbstractArray{T,1}
data::Array{T,1}
end
Base.IndexStyle(::Type{A}) where {A<:TestVec} = Base.IndexCartesian()
Base.size(A::TestVec) = size(getfield(A, :data))
Base.getindex(A::TestVec, index::Int) = getindex(getfield(A, :data), index)
Base.collect(::Type{T}, itr::TestVec) where {T} = TestVec(collect(T, getfield(itr, :data)))
Base.convert(::Type{<:TestVec}, x::Array) = TestVec(x)
end
6.1 ms
👀 Reading hidden code
begin
struct MinimalTable
data::Matrix
colnames::TestVec
end

Tables.istable(x::MinimalTable) = true
Tables.columnaccess(::MinimalTable) = true
Tables.columnnames(x::MinimalTable) = getfield(x, :colnames)
Tables.columns(x::MinimalTable) = x
Base.getindex(x::MinimalTable, i1, i2) = getindex(getfield(x, :data), i1, i2)
Base.getproperty(x::MinimalTable, s::Symbol) = getindex(x, :, findfirst(==(s), Tables.columnnames(x)))
end
3.9 ms
3×3 Matrix{Float64}:
 0.212798   0.603537   0.429298
 0.717627   0.0663684  0.959119
 0.0334289  0.692403   0.473176
data = rand(3,3)
👀 Reading hidden code
14.6 μs
mt = MinimalTable(data, [Symbol("Col. 1"), Symbol("Col. 2"), Symbol("Col. 3")])
👀 Reading hidden code
25.7 μs
table = (A = Int64.(1:10),
B = Float64.(1:10),
C = Int64.(1:10),
D = Float64.(1:10))
👀 Reading hidden code
76.1 ms
ABCD
Int64Float64Int64Float64
1
1
1.0
1
1.0
2
2
2.0
2
2.0
3
3
3.0
3
3.0
4
4
4.0
4
4.0
5
5
5.0
5
5.0
6
6
6.0
6
6.0
7
7
7.0
7
7.0
8
8
8.0
8
8.0
9
9
9.0
9
9.0
10
10
10.0
10
10.0
t = Tables.rows(table)
👀 Reading hidden code
4.3 ms
using DataFrames
👀 Reading hidden code
1.3 s
DataFrame
DataFrame
👀 Reading hidden code
9.1 μs
"Tables.RowIterator{NamedTuple{(:A, :B, :C, :D), Tuple{Vector{Int64}, Vector{Float64}, Vector{Int64}, Vector{Float64}}}}((A = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], B = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0], C = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], D = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]), 10)"
string(t)
👀 Reading hidden code
191 ms
@which Tables.rowaccess(t)
👀 Reading hidden code
102 ms