DataFrames.jl icon indicating copy to clipboard operation
DataFrames.jl copied to clipboard

`join` should not introduce `Missing` types to schema

Open adienes opened this issue 3 months ago • 1 comments

julia> using DataFrames

julia> df1 = DataFrame([:a => [1,2,3], :b=>[4, 5, 6]])
3×2 DataFrame
 Row │ a      b     
     │ Int64  Int64 
─────┼──────────────
   1 │     1      4
   2 │     2      5
   3 │     3      6

julia> df2 = DataFrame([:a => [1,2,3], :c=>[7, 8, 9]])
3×2 DataFrame
 Row │ a      c     
     │ Int64  Int64 
─────┼──────────────
   1 │     1      7
   2 │     2      8
   3 │     3      9

julia> leftjoin(df1, df2; on=:a)
3×3 DataFrame
 Row │ a      b      c      
     │ Int64  Int64  Int64? 
─────┼──────────────────────
   1 │     1      4       7
   2 │     2      5       8
   3 │     3      6       9

there are no missing values after the join so it is quite unfortunate that the type of c in the resulting table is a union with Missing

adienes avatar Mar 20 '24 16:03 adienes