Closed
Description
I have a pyconvert_add_rule
in Julia that accepts a Py object wrapping pandas DataFrame, reads its columns, wraps PyArray around each column, add it to Julia DataFrame, all without copying. So I'm able to fetch a pandas DataFrame from inside Julia.
But I'm not able to activate this chain trying to pass from Python to Julia. It converts the pandas DataFrame to a PyObject instead of PyPandasDataFrame. I overrode convert rule to accept PyObject, but it seems to have trouble accessing its columns. I get the following RuntimeError trying to convert it:
In [9]: jl.convert(DataFrames.DataFrame, bm1)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Input In [9], in <cell line: 1>()
----> 1 jl.convert(DataFrames.DataFrame, bm1)
RuntimeError: <PyCall.jlwrap (in a Julia function called from Python)
JULIA: UndefRefError: access to undefined reference
Stacktrace:
[1] PyType_IsSubtype
@ C:\Users\kirby\.julia\packages\PythonCall\4eoCM\src\cpython\pointers.jl:297 [inlined]
[2] PyJuliaValue_New(t::Ptr{PythonCall.C.PyObject}, v::Any)
@ PythonCall.C C:\Users\kirby\.julia\packages\PythonCall\4eoCM\src\cpython\jlwrap.jl:314
[3] pyjl
@ C:\Users\kirby\.julia\packages\PythonCall\4eoCM\src\jlwrap\base.jl:7 [inlined]
[4] pyjl
@ C:\Users\kirby\.julia\packages\PythonCall\4eoCM\src\jlwrap\any.jl:321 [inlined]
[5] Py
@ C:\Users\kirby\.julia\packages\PythonCall\4eoCM\src\Py.jl:157 [inlined]
[6] macro expansion
@ C:\Users\kirby\.julia\packages\PythonCall\4eoCM\src\Py.jl:136 [inlined]
[7] pyconvert(#unused#::Type{DataFrames.DataFrame}, x::PyObject)
@ PythonCall C:\Users\kirby\.julia\packages\PythonCall\4eoCM\src\convert.jl:370
[8] convert(#unused#::Type{DataFrames.DataFrame}, x::PyObject)
@ Conversions C:\Users\kirby\MyDrive\Documents\thirdwave\julia\Conversions.jl:27
[9] invokelatest(::Any, ::Any, ::Vararg{Any}; kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ Base .\essentials.jl:716
[10] invokelatest(::Any, ::Any, ::Vararg{Any})
@ Base .\essentials.jl:714
[11] _pyjlwrap_call(f::Function, args_::Ptr{PyCall.PyObject_struct}, kw_::Ptr{PyCall.PyObject_struct})
@ PyCall C:\Users\kirby\.julia\packages\PyCall\7a7w0\src\callback.jl:28
[12] pyjlwrap_call(self_::Ptr{PyCall.PyObject_struct}, args_::Ptr{PyCall.PyObject_struct}, kw_::Ptr{PyCall.PyObject_struct})
@ PyCall C:\Users\kirby\.julia\packages\PyCall\7a7w0\src\callback.jl:44>
Metadata
Metadata
Assignees
Labels
No labels