JuliaData / JuliaData/DataFrames.jl

Initializing Dataframe from vector of named tuples: missing values

Open
#3,370 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

decision
Dominant language
Julia
Stars
1.8k
Forks
372
Avg merge
5d 7h
Merged PRs (30d)
5

Description

When I initialize my dataframe using

df = DataFrame([(a=1,b=2), (a=3,b=4), (a=1,)])

I would expect to get

a b
1 2
3 4
1 missing

Instead I get an error

ERROR: type NamedTuple has no field b
Stacktrace:
  [1] getproperty
    @ ./Base.jl:37 [inlined]
  [2] getcolumn
    @ ~/.julia/packages/Tables/AcRIE/src/Tables.jl:102 [inlined]

Is there a simple way to get the former behavior? Should it be what DataFrames does by default instead of throwing an error?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the DataFrame constructor example and inspect Tables.jl getcolumn at the location shown in the stack trace. Determine the intended handling for an absent named-tuple field, then verify that the example produces column b values 2, 4, and missing.

Written by the indexing model from the issue text.

Assessment

Tech stack
julia
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.