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

Warning when Joining on two columns with different datatypes #3486

Closed
moalk101 opened this issue Feb 4, 2025 · 1 comment
Closed

Warning when Joining on two columns with different datatypes #3486

moalk101 opened this issue Feb 4, 2025 · 1 comment

Comments

@moalk101
Copy link

moalk101 commented Feb 4, 2025

So I had an issue with innerjoin. When joining two DataFrames where the columns specified in on= :c1 => :c2 have different datatypes but the same values(one is a string and the other is of type Int64), the result is always an empty DataFrame. It took me a while until I figured it out.
Is it possible to build in a Warning or an Error when joining on Columns with different DataTypes?
Example:

julia> df1 = DataFrame(
           Age = ["25", "30", "35"],
           C11 = [50000.0, 60000.0, 70000.0]
       )

3×2 DataFrame
 Row │ Age     C11     
     │ String  Float64 
─────┼─────────────────
   1 │ 25      50000.0
   2 │ 30      60000.0
   3 │ 35      70000.0

julia> df2 = DataFrame(
            Age = [25, 30, 35],
             C22 = [50000.0, 60000.0, 70000.0]
       )

3×2 DataFrame
 Row │ Age    C22     
     │ Int64  Float64 
─────┼────────────────
   1 │    25  50000.0
   2 │    30  60000.0
   3 │    35  70000.0

julia> innerjoin(df2,df1,on= :Age => :Age)
0×3 DataFrame
 Row │ Age    C22      C11     
     │ Int64  Float64  Float64 
─────┴─────────────────────────

Thank you in advance!

@bkamins
Copy link
Member

bkamins commented Feb 5, 2025

We cannot add this warning, since it if quite common to have columns of element type Any, which can store anything. Unfortunately, from Julia's perspective number 1 and string "1" are just two different values.

@bkamins bkamins closed this as completed Feb 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants