Skip to content

Error when getting columns on PyPandasDataFrame #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nardi opened this issue Jun 16, 2021 · 1 comment
Closed

Error when getting columns on PyPandasDataFrame #23

nardi opened this issue Jun 16, 2021 · 1 comment

Comments

@nardi
Copy link

nardi commented Jun 16, 2021

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.

@cjdoris
Copy link
Collaborator

cjdoris commented Jun 21, 2021

Thanks, now fixed on master.

@cjdoris cjdoris closed this as completed Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants