Skip to content
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

Error in any graph #27

Closed
egolep opened this issue Aug 24, 2021 · 4 comments
Closed

Error in any graph #27

egolep opened this issue Aug 24, 2021 · 4 comments

Comments

@egolep
Copy link

egolep commented Aug 24, 2021

For any graph I try to use, I get errors. For example, trying to use a catplot I get:

ERROR: PyError ($(Expr(:escape, :(ccall(#= /home/egolep/.julia/packages/PyCall/BD546/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'TypeError'>
TypeError("'PyCall.jlwrap' object is not subscriptable")
File "/home/egolep/.local/lib/python3.9/site-packages/seaborn/_decorators.py", line 46, in inner_f
return f(**kwargs)
File "/home/egolep/.local/lib/python3.9/site-packages/seaborn/regression.py", line 605, in lmplot
data = data[cols]

Stacktrace:
[1] pyerr_check
@ ~/.julia/packages/PyCall/BD546/src/exception.jl:62 [inlined]
[2] pyerr_check
@ ~/.julia/packages/PyCall/BD546/src/exception.jl:66 [inlined]
[3] _handle_error(msg::String)
@ PyCall ~/.julia/packages/PyCall/BD546/src/exception.jl:83
[4] macro expansion
@ ~/.julia/packages/PyCall/BD546/src/exception.jl:97 [inlined]
[5] #107
@ ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:43 [inlined]
[6] disable_sigint
@ ./c.jl:458 [inlined]
[7] __pycall!
@ ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:42 [inlined]
[8] _pycall!(ret::PyObject, o::PyObject, args::Tuple{}, nargs::Int64, kw::PyObject)
@ PyCall ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:29
[9] _pycall!
@ ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:11 [inlined]
[10] (::PyObject)(; kwargs::Base.Iterators.Pairs{Symbol, DataFrames.DataFrame, Tuple{Symbol}, NamedTuple{(:data,), Tuple{DataFrames.DataFrame}}})
@ PyCall ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:86
[11] lmplot(; kwargs::Base.Iterators.Pairs{Symbol, DataFrames.DataFrame, Tuple{Symbol}, NamedTuple{(:data,), Tuple{DataFrames.DataFrame}}})
@ Seaborn ~/.julia/packages/Seaborn/vfmph/src/Seaborn.jl:61
[12] top-level scope
@ REPL[53]:1

Or for a lmplot I get:

ERROR: PyError ($(Expr(:escape, :(ccall(#= /home/egolep/.julia/packages/PyCall/BD546/src/pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class 'TypeError'>
TypeError("'PyCall.jlwrap' object is not subscriptable")
File "/home/egolep/.local/lib/python3.9/site-packages/seaborn/_decorators.py", line 46, in inner_f
return f(**kwargs)
File "/home/egolep/.local/lib/python3.9/site-packages/seaborn/regression.py", line 605, in lmplot
data = data[cols]

Stacktrace:
[1] pyerr_check
@ ~/.julia/packages/PyCall/BD546/src/exception.jl:62 [inlined]
[2] pyerr_check
@ ~/.julia/packages/PyCall/BD546/src/exception.jl:66 [inlined]
[3] _handle_error(msg::String)
@ PyCall ~/.julia/packages/PyCall/BD546/src/exception.jl:83
[4] macro expansion
@ ~/.julia/packages/PyCall/BD546/src/exception.jl:97 [inlined]
[5] #107
@ ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:43 [inlined]
[6] disable_sigint
@ ./c.jl:458 [inlined]
[7] __pycall!
@ ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:42 [inlined]
[8] _pycall!(ret::PyObject, o::PyObject, args::Tuple{}, nargs::Int64, kw::PyObject)
@ PyCall ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:29
[9] pycall!(ret::PyObject, o::PyObject, args::Tuple{}, kwargs::Base.Iterators.Pairs{Symbol, Any, NTuple{7, Symbol}, NamedTuple{(:x, :y, :hue, :col, :data, :col_wrap, :height), Tuple{String, String, String, String, DataFrames.DataFrame, Int64, Int64}}})
@ PyCall ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:11
[10] #
#114
@ ~/.julia/packages/PyCall/BD546/src/pyfncall.jl:86 [inlined]
[11] lmplot(; kwargs::Base.Iterators.Pairs{Symbol, Any, NTuple{7, Symbol}, NamedTuple{(:x, :y, :hue, :col, :data, :col_wrap, :height), Tuple{String, String, String, String, DataFrames.DataFrame, Int64, Int64}}})
@ Seaborn ~/.julia/packages/Seaborn/vfmph/src/Seaborn.jl:61
[12] top-level scope
@ REPL[56]:1

Is it a problem with my version o Python? I also tried to use PyCall with Conda instead of my system version of Python, but with no difference (I don't also know if Seaborn.jl actually uses PyCall)

@ShuhuaGao
Copy link

ShuhuaGao commented Aug 24, 2021

Note that the dataframe required by Seaborn.jl is Pandas.DataFrame instead of DataFrames.DataFrame. Check https://github.com/JuliaPy/Pandas.jl for details.

Run the official example in Julia 1.6.0:

import Seaborn as sns
tips = sns.load_dataset("tips")
typeof(tips) # Pandas.DataFrame

sns.boxplot(x="day", y="total_bill", data=tips)

@malmaud
Copy link
Contributor

malmaud commented Aug 24, 2021

@ShuhuaGao is right. I would support a feature that autoconverts the input to Seaborn functions from DataFrames.DataFrame to Pandas.DataFrame so your example would work seamlessly - PRs welcome!

@malmaud malmaud closed this as completed Aug 24, 2021
@ShuhuaGao
Copy link

autoconverts the input to Seaborn functions from DataFrames.DataFrame to Pandas.DataFrame

Pandas supports such manual conversion. For now, I suggest mentioning this issue and the workaround in the README. I encountered this issue at the beginning as well and thought that DataFrames.DataFrame was allowed.

julia> using DataFrames

julia> import Pandas as pd

julia> jdf = DataFrame(x=[1, 2], y=[2.3, -1]);

julia> pd.DataFrame(jdf)  # to Pandas.DataFrame
     y  x
0  2.3  1
1 -1.0  2

@egolep
Copy link
Author

egolep commented Aug 28, 2021

Thanks to everyone

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

3 participants