JuliaData / JuliaData/JSONTables.jl
arraytable (objecttable) fails when the argument is a nested table
Nobody has claimed this yet.
- Dominant language
- Julia
- Stars
- 71
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
I wanted to see the json file corresponding to a dataframe that has dataframes as elements in one of the columns.
3×3 DataFrame
Row │ f oc sdf
│ String Int64 DataFrame
─────┼──────────────────────────────
1 │ f1 1 3×2 DataFrame
2 │ f2 2 2×2 DataFrame
3 │ f3 3 3×2 DataFrame
I have previously verified that
julia> Tables.istable(dfn)
true
but I get this result
julia> objecttable(dfn)
ERROR: ArgumentError: DataFrame doesn't have a defined `StructTypes.StructType`
Stacktrace:
...
I wonder if it is possible to manage this type of structures
if i use jsontable on this string (http://bl.ocks.org/nautat/4085017)
jdata = "[
{
\"name\":\"bob\",
\"salary\":13000,
\"friends\":[
{
\"name\": \"sarah\",
\"salary\":10000
},
{
\"name\": \"bill\",
\"salary\":5000
}
]
},
{
\"name\":\"marge\",
\"salary\":10000,
\"friends\":[
{
\"name\": \"rhonda\",
\"salary\":10000
},
{
\"name\": \"mike\",
\"salary\":5000,
\"hobbies\":[
{
\"name\":\"surfing\",
\"frequency\":10
},
{
\"name\":\"surfing\",
\"frequency\":15
}
]
}
]
},
{
\"name\":\"joe\",
\"salary\":10000,
\"friends\":[
{
\"name\": \"harry\",
\"salary\":10000
},
{
\"name\": \"sally\",
\"salary\":5000
}
]
}
]"
and then i try to get the dataframe
julia> jsontable(jdata)
JSONTables.Table{false, JSON3.Array{JSON3.Object, Base.CodeUnits{UInt8, String}, Vector{UInt64}}}([:name, :salary, :friends], Dict{Symbol, Type}(:name => String, :salary => Int64, :friends => JSON3.Array{JSON3.Object, Base.CodeUnits{UInt8, String}, SubArray{UInt64, 1, Vector{UInt64}, Tuple{UnitRange{Int64}}, true}}), JSON3.Object[{
...
julia> DataFrame(jsontable(jdata))
3×3 DataFrame
Row │ name salary friends
│ String Int64 Array…
─────┼───────────────────────────────────────────────────
1 │ bob 13000 JSON3.Object[{\n "name": "sa…
2 │ marge 10000 JSON3.Object[{\n "name": "rh…
3 │ joe 10000 JSON3.Object[{\n "name": "ha…
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the nested-DataFrame example with objecttable(dfn) and compare it with the jsontable and DataFrame(jsontable(jdata)) entry points shown in the issue. Determine the expected representation for nested tables, then add coverage for that case and verify it no longer fails with the missing StructTypes.StructType error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- json, julia
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100