Skip to content

append! NamedTuple to Table lead to strange behavior #116

@femtotrader

Description

@femtotrader

Hello,

I was trying to append! a NamedTuple to Table... and noticed this odd behiavor

julia> t = Table(a = [1, 2, 3], b = [2.0, 4.0, 6.0])
Table with 2 columns and 3 rows:
     a  b
   ┌───────
 11  2.0
 22  4.0
 33  6.0

julia> append!(t, (a=4, b=8.0))
ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type @NamedTuple{a::Int64, b::Float64}

Closest candidates are:
  convert(::Type{NT}, ::NT) where {names, T<:Tuple, NT<:NamedTuple{names, T}}
   @ Base namedtuple.jl:184
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:84
  convert(::Type{NT}, ::NamedTuple{names}) where {names, T<:Tuple, NT<:NamedTuple{names, T}}
   @ Base namedtuple.jl:186
  ...

Stacktrace:
 [1] setindex!
   @ C:\Users\femto\.julia\packages\TypedTables\ItVth\src\Table.jl:142 [inlined]
 [2] _append!
   @ .\array.jl:1201 [inlined]
 [3] append!(a::Table{@NamedTuple{…}, 1, @NamedTuple{…}}, iter::@NamedTuple{a::Int64, b::Float64})
   @ Base .\array.jl:1187
 [4] top-level scope
   @ REPL[31]:1
Some type information was truncated. Use `show(err)` to see complete types.

julia> t
Table with 2 columns and 5 rows:
     a  b
   ┌────────────
 11  2.0
 22  4.0
 33  6.0
 43  1.0e-323
 53  1.0e-323

These 2 rows are intriguing

 4 │ 3  1.0e-323
 5 │ 3  1.0e-323

Any idea what is causing that?

Would it be possible to append! a NamedTuple to a Table (without creating a Table from NamedTuple)

Kind regards

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions