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

Try to_pandas rather than erroring if interchanging to pandas doesn't work? #3533

Open
MarcoGorelli opened this issue Oct 19, 2023 · 0 comments · May be fixed by #3782
Open

Try to_pandas rather than erroring if interchanging to pandas doesn't work? #3533

MarcoGorelli opened this issue Oct 19, 2023 · 0 comments · May be fixed by #3782

Comments

@MarcoGorelli
Copy link
Contributor

Here's an example of some code which currently raises:

import seaborn as sns
import polars as pl
df = pl.DataFrame({'a': [1,2,3], 'b': [4,5,6], 'c': [[1,2], [4,5], [6,7]]})
sns.catplot(
    data=df,
    x="a",
    y="b",
)

There's a really long error message, but the gist of it is

ValueError: data type List(Int64) not supported by the interchange protocol

Indeed, just doing

pd.api.interchange.from_pandas(df)

would raise the same error

I'd like to suggest that, when converting to pandas, if the interchange protocol fails, there be a to_pandas fallback.

Because that at least works here (for reference, plotly do the same - try interchanging first, and if that fails, check if there's to_pandas, and if so, use that)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants