Skip to content

Pandas new definition of operator == can cause error #95

@alexander-wise

Description

@alexander-wise

By convention, the == operator should never throw an error message. However, the following code causes an error:

import Pandas
test_df = Pandas.DataFrame(Dict(:a => [1,2], :b => [3,4]))
test_df == any #this causes an error, correct output should be false

Another example would be:

...
test_df == Base

The more specific reason this is a problem for me, besides going against convention for the operator, is that the Julia extension for Visual Studio code compares ALL variable names to some Julia functions/packages using == as part of its bookkeeping for every input, so the extension's Julia REPL terminal crashes any time a Pandas DataFrame is defined.

In case this helps, here is the full stacktrace (running Julia 1.6.2) for the error message from the above code

ERROR: (in a Julia function called from Python)
JULIA: MethodError: no method matching iterate(::Module)
Closest candidates are:
iterate(!Matched::Union{LinRange, StepRangeLen}) at range.jl:664
iterate(!Matched::Union{LinRange, StepRangeLen}, !Matched::Int64) at range.jl:664
iterate(!Matched::T) where T<:Union{Base.KeySet{var"#s79", var"#s78"} where {var"#s79", var"#s78"<:Dict}, Base.ValueIterator{var"#s77"} where var"#s77"<:Dict} at dict.jl:693
...
Stacktrace:
[1] jlwrap_iterator(o::Module)
@ PyCall ~/.julia/packages/PyCall/7a7w0/src/pyiterator.jl:144
[2] pyjlwrap_getiter(self_::Ptr{PyCall.PyObject_struct})
@ PyCall ~/.julia/packages/PyCall/7a7w0/src/pyiterator.jl:125
[3] macro expansion
@ ~/.julia/packages/PyCall/7a7w0/src/exception.jl:95 [inlined]
[4] #107
@ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:43 [inlined]
[5] disable_sigint
@ ./c.jl:458 [inlined]
[6] __pycall!
@ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:42 [inlined]
[7] _pycall!(ret::PyCall.PyObject, o::PyCall.PyObject, args::Tuple{Module}, nargs::Int64, kw::Ptr{Nothing})
@ PyCall ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:29
[8] pycall!
@ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:11 [inlined]
[9] #
#114
@ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:86 [inlined]
[10] PyObject
@ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:86 [inlined]
[11] ==(x::DataFrame, y::Module)
@ Pandas ~/.julia/packages/Pandas/y8TBE/src/Pandas.jl:385
[12] top-level scope
@ REPL[8]:1
[13] eval
@ ./boot.jl:360 [inlined]
[14] eval_user_input(ast::Any, backend::REPL.REPLBackend)
@ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:139
[15] repl_backend_loop(backend::REPL.REPLBackend)
@ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:200
[16] start_repl_backend(backend::REPL.REPLBackend, consumer::Any)
@ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:185
[17] run_repl(repl::REPL.AbstractREPL, consumer::Any; backend_on_current_task::Bool)
@ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:317
[18] run_repl(repl::REPL.AbstractREPL, consumer::Any)
@ REPL /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v1.6/REPL/src/REPL.jl:305
[19] (::Base.var"#874#876"{Bool, Bool, Bool})(REPL::Module)
@ Base ./client.jl:387
[20] #invokelatest#2
@ ./essentials.jl:708 [inlined]
[21] invokelatest
@ ./essentials.jl:706 [inlined]
[22] run_main_repl(interactive::Bool, quiet::Bool, banner::Bool, history_file::Bool, color_set::Bool)
@ Base ./client.jl:372
[23] exec_options(opts::Base.JLOptions)
@ Base ./client.jl:302
[24] _start()
@ Base ./client.jl:485
Stacktrace:
[1] pyerr_check
@ ~/.julia/packages/PyCall/7a7w0/src/exception.jl:62 [inlined]
[2] pyerr_check
@ ~/.julia/packages/PyCall/7a7w0/src/exception.jl:66 [inlined]
[3] _handle_error(msg::String)
@ PyCall ~/.julia/packages/PyCall/7a7w0/src/exception.jl:83
[4] macro expansion
@ ~/.julia/packages/PyCall/7a7w0/src/exception.jl:97 [inlined]
[5] #107
@ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:43 [inlined]
[6] disable_sigint
@ ./c.jl:458 [inlined]
[7] __pycall!
@ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:42 [inlined]
[8] _pycall!(ret::PyCall.PyObject, o::PyCall.PyObject, args::Tuple{Module}, nargs::Int64, kw::Ptr{Nothing})
@ PyCall ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:29
[9] pycall!
@ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:11 [inlined]
[10] #
#114
@ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:86 [inlined]
[11] PyObject
@ ~/.julia/packages/PyCall/7a7w0/src/pyfncall.jl:86 [inlined]
[12] ==(x::DataFrame, y::Module)
@ Pandas ~/.julia/packages/Pandas/y8TBE/src/Pandas.jl:385
[13] top-level scope
@ REPL[8]:1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions