Skip to content

Python to Julia dataframe conversion broken by pandas v3.0 #745

@sstroemer

Description

@sstroemer

Affects: Both

Using pandas version 3.0.0 the pd.DataFrame to DataFrames.DataFrame conversion is broken.

The following snippet

df = pd.DataFrame({
    "foo": [1, 2, 3],
    "bar": [4, 5, 6],
})
jl.DataFrames.DataFrame(df)

results in

juliacall.JuliaError: ArgumentError: 'PyIterable{Any}' iterates 'String' values, which doesn't satisfy the Tables.jl `AbstractRow` interface
Stacktrace:
  [1] invalidtable(::PyIterable{Any}, ::String)
    @ Tables ~/.julia/packages/Tables/cRTb7/src/tofromdatavalues.jl:41
  [2] iterate
    @ ~/.julia/packages/Tables/cRTb7/src/tofromdatavalues.jl:47 [inlined]
  [3] buildcolumns
    @ ~/.julia/packages/Tables/cRTb7/src/fallbacks.jl:209 [inlined]
  [4] _columns
    @ ~/.julia/packages/Tables/cRTb7/src/fallbacks.jl:274 [inlined]
  [5] columns
    @ ~/.julia/packages/Tables/cRTb7/src/fallbacks.jl:258 [inlined]
  [6] DataFrames.DataFrame(x::PyIterable{Any}; copycols::Nothing)
    @ DataFrames ~/.julia/packages/DataFrames/b4w9K/src/other/tables.jl:57
  [7] DataFrames.DataFrame(x::PyIterable{Any})
    @ DataFrames ~/.julia/packages/DataFrames/b4w9K/src/other/tables.jl:48
  [8] pyjlany_call(self::Type{DataFrames.DataFrame}, args_::Py, kwargs_::Py)
    @ PythonCall.JlWrap ~/.julia/packages/PythonCall/mkWc2/src/JlWrap/any.jl:47
  [9] _pyjl_callmethod(f::Any, self_::Ptr{PythonCall.C.PyObject}, args_::Ptr{PythonCall.C.PyObject}, nargs::Int64)
    @ PythonCall.JlWrap ~/.julia/packages/PythonCall/mkWc2/src/JlWrap/base.jl:71
 [10] _pyjl_callmethod(o::Ptr{PythonCall.C.PyObject}, args::Ptr{PythonCall.C.PyObject})
    @ PythonCall.JlWrap.Cjl ~/.julia/packages/PythonCall/mkWc2/src/JlWrap/C.jl:63

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions