How to create JuliaDB table from DataFrame?


#1

I thought it would be easy but…

julia> df = DataFrame(x = [1,2,3], y = [4,5,6])
3×2 DataFrames.DataFrame
│ Row │ x │ y │
├─────┼───┼───┤
│ 1   │ 1 │ 4 │
│ 2   │ 2 │ 5 │
│ 3   │ 3 │ 6 │

julia> t = table(df)
ERROR: ArgumentError: iter cannot be turned into a NextTable.
Stacktrace:
 [1] #table#334(::Bool, ::Array{Any,1}, ::Function, ::DataFrames.DataFrame) at /Users/tomkwong/.julia/v0.6/IndexedTables/src/tabletraits.jl:68
 [2] table(::DataFrames.DataFrame) at /Users/tomkwong/.julia/v0.6/IndexedTables/src/tabletraits.jl:65

#2

I can work around with the following. It looks like a bug with JuliaDB and I will submit an issue as such.

julia> table([df[c] for c in names(df)]...; names = names(df))
Table with 3 rows, 2 columns:
x  y
────
1  4
2  5
3  6

#3

To convert, you need to load using IterableTables

julia> using IterableTables

julia> table(df)
Table with 3 rows, 2 columns:
x  y
────
1  4
2  5
3  6