-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Description
Adding/removing rows to/from DictTables only seems to work when the index column does not have a name, e.g., when the table is constructed from dictionaries:
julia> idx = [1, 2, 3]; dt = DictTable(name = Dictionary(idx, ["A", "B", "C"]))
DictTable with 1 column and 3 rows:
name
┌─────
1 │ A
2 │ B
3 │ C
julia> delete!(dt, 1)
DictTable with 1 column and 2 rows:
name
┌─────
2 │ B
3 │ C
julia> insert!(dt, 4, (name = "D",))
DictTable with 1 column and 3 rows:
name
┌─────
2 │ B
3 │ C
4 │ DHowever, when creating a DictTable with a named index column, insert! and delete! throw errors:
julia> dt = DictTable(idx = [1, 2, 3], name = ["A", "B", "C"])
DictTable with 1 column and 3 rows:
idx name
────┬─────
1 │ A
2 │ B
3 │ C
julia> delete!(dt, 1)
ERROR: TypeError: in Tokenized, in Parent, expected Parent<:AbstractDictionary, got Type{Int64}
Stacktrace:
[1] tokenized(d::Indices{Int64})
@ Dictionaries ~/.julia/packages/Dictionaries/7aBxp/src/tokens.jl:146
[2] map
@ ./tuple.jl:274 [inlined]
[3] map(::Function, ::NamedTuple{(:idx, :name), Tuple{Indices{Int64}, Dictionary{Int64, String}}})
@ Base ./namedtuple.jl:219
[4] deletetoken!(d::DictTable{Int64, NamedTuple{(:idx, :name), Tuple{Int64, String}}, NamedTuple{(:idx, :name), Tuple{Indices{Int64}, Dictionary{Int64, String}}}, Indices{Int64}}, t::Tuple{Int64, Int64})
@ TypedTables ~/.julia/packages/TypedTables/4OVef/src/DictTable.jl:170
[5] delete!(d::DictTable{Int64, NamedTuple{(:idx, :name), Tuple{Int64, String}}, NamedTuple{(:idx, :name), Tuple{Indices{Int64}, Dictionary{Int64, String}}}, Indices{Int64}}, i::Int64)
@ Dictionaries ~/.julia/packages/Dictionaries/7aBxp/src/insertion.jl:293
[6] top-level scope
@ REPL[86]:1
julia> insert!(dt, 4, (idx = 4, name = "D"))
ERROR: TypeError: in Tokenized, in Parent, expected Parent<:AbstractDictionary, got Type{Int64}
Stacktrace:
[1] tokenized(d::Indices{Int64})
@ Dictionaries ~/.julia/packages/Dictionaries/7aBxp/src/tokens.jl:146
[2] map
@ ./tuple.jl:274 [inlined]
[3] map(::Function, ::NamedTuple{(:idx, :name), Tuple{Indices{Int64}, Dictionary{Int64, String}}})
@ Base ./namedtuple.jl:219
[4] gettoken!(d::DictTable{Int64, NamedTuple{(:idx, :name), Tuple{Int64, String}}, NamedTuple{(:idx, :name), Tuple{Indices{Int64}, Dictionary{Int64, String}}}, Indices{Int64}}, i::Int64)
@ TypedTables ~/.julia/packages/TypedTables/4OVef/src/DictTable.jl:166
[5] insert!(d::DictTable{Int64, NamedTuple{(:idx, :name), Tuple{Int64, String}}, NamedTuple{(:idx, :name), Tuple{Indices{Int64}, Dictionary{Int64, String}}}, Indices{Int64}}, i::Int64, value::NamedTuple{(:idx, :name), Tuple{Int64, String}})
@ Dictionaries ~/.julia/packages/Dictionaries/7aBxp/src/insertion.jl:133
[6] top-level scope
@ REPL[87]:1(Tested with Julia 1.9.3)
Metadata
Metadata
Assignees
Labels
No labels