You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
julia> df =DataFrame()
0×0 DataFrame
julia>push!(df, NamedTuple(); cols=:union) # does not add a row0×0 DataFrame
julia> df =DataFrame(:a=> [1]) # try again with non-empty df1×1 DataFrame
Row │ a
│ Int64
─────┼───────
1 │ 1
julia>push!(df, NamedTuple(); cols=:union) # adds a row2×1 DataFrame
Row │ a
│ Int64?
─────┼─────────
1 │ 12 │ missing
This edge case came up for me when doing
new_df =DataFrame()
for value in old_df.col
push!(new_df, nt_with_variable_number_cols(value); cols=:union)
end
df =hcat(old_df, new_df; copycols=false)
I can see the problem. The question is what to do about it. If the data frame has no columns then pushing NamedTuple() cannot add a row to it.
On the other hand, if a data frame already has some data and you push NamedTuple() to it with cols=:union I think that it is natural to expect that a row full of missing values will be created.
In general Tables.dictrowtable is a function designed to perform such unioning as you want:
This edge case came up for me when doing
to try to work around the fact that
does not work (says you must emit identical columns).
The text was updated successfully, but these errors were encountered: