Skip to content

Error when getting columns on PyPandasDataFrame #23

Closed
@nardi

Description

@nardi

When running the following example code:

using PythonCall
using Tables

@pyg `
import numpy as np
import pandas as pd

$x = pd.DataFrame(np.array((100, 100)))`

# Make sure the columns are strings, or it will fail in any case.
@pyg `$x.columns = map(str, $x.columns)`

y = PyPandasDataFrame(x)
Tables.columns(y)

I get the error:

ERROR: LoadError: map is not defined on sets
Stacktrace:
 [1] error(s::String)
   @ Base .\error.jl:33
 [2] map(f::Type, #unused#::Base.KeySet{String, PyPandasDataFrame})
   @ Base .\abstractarray.jl:2326
 [3] columns(x::PyPandasDataFrame)
   @ PythonCall [,,,]\.julia\packages\PythonCall\MBkDb\src\PyPandasDataFrame.jl:155

This could be fixed by changing the map call on line 155 to map(Symbol, collect(keys(x))) instead.

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