Hi! suppose I have a DataFrame
where some of the entries have been rounded to -0.0
.
df1 = DataFrame(x = [ 1, 0, -0.0])
3×1 DataFrame
Row │ x
│ Float64
─────┼─────────
1 │ 1.0
2 │ 0.0
3 │ -0.0
julia> df2 = DataFrame(x = [ 1, 0, 0])
3×1 DataFrame
Row │ x
│ Int64
─────┼───────
1 │ 1
2 │ 0
3 │ 0
when I try
julia> antijoin(df1,df2, on=(:x))
rather than en empty DataFrame
the following error is raised
ERROR: ArgumentError: currently for numeric values NaN and `-0.0` in their real or imaginary components are not allowed. Use CategoricalArrays.jl to wrap these values in a CategoricalVector to perform the requested join.
Stacktrace:
[1] DataFrames.DataFrameJoiner(dfl::DataFrame, dfr::DataFrame, on::Symbol, matchmissing::Symbol, kind::Symbol)
@ DataFrames ~/.julia/packages/DataFrames/LteEl/src/join/composer.jl:94
[2] _join(df1::DataFrame, df2::DataFrame; on::Symbol, kind::Symbol, makeunique::Bool, indicator::Nothing, validate::Tuple{Bool, Bool}, left_rename::typeof(identity), right_rename::typeof(identity), matchmissing::Symbol, order::Symbol)
@ DataFrames ~/.julia/packages/DataFrames/LteEl/src/join/composer.jl:497
[3] #antijoin#674
@ ~/.julia/packages/DataFrames/LteEl/src/join/composer.jl:1488 [inlined]
[4] top-level scope
@ REPL[260]:1
However when I try using CategoricalArrays
as per Error
raised I get the following result
julia> df4 = DataFrame(x = categorical([1,0,-0.0]))
3×1 DataFrame
Row │ x
│ Cat…
─────┼──────
1 │ 1.0
2 │ 0.0
3 │ -0.0
julia> antijoin(df4,df2, on=(:x))
1×1 DataFrame
Row │ x
│ Cat…
─────┼──────
1 │ -0.0
As opposed to an empty DataFrame
. I’m a little confused by this because
df4.x[3]==df2.x[2]
true
and
0.0 == -0.0
true
Just wondering if anyone could provide some insight as to where my understanding went wrong? Thanks!