Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

join should not introduce Missing types to schema #3431

Open
adienes opened this issue Mar 20, 2024 · 1 comment
Open

join should not introduce Missing types to schema #3431

adienes opened this issue Mar 20, 2024 · 1 comment
Labels

Comments

@adienes
Copy link

adienes commented Mar 20, 2024

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

@bkamins
Copy link
Member

bkamins commented Mar 20, 2024

It is an union, because there could be missings in :c if df2 did not have all keys (which cannot be checked upfront). You can use disallowmissing! after the join.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants