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

Vegafusion and altair: Expected Table-like input... #556

Closed
firasm opened this issue Jan 26, 2025 · 4 comments
Closed

Vegafusion and altair: Expected Table-like input... #556

firasm opened this issue Jan 26, 2025 · 4 comments

Comments

@firasm
Copy link

firasm commented Jan 26, 2025

Hello,

Running on Altair 5.5.0 and vegafusion 2.0.1, I am trying to reduce the size of a notebook by following the advice on large datasets here.

I get an error when creating a chart:

File [~/.pyenv/versions/3.12.1/lib/python3.12/site-packages/vegafusion/runtime.py:330](http://localhost:8889/~/.pyenv/versions/3.12.1/lib/python3.12/site-packages/vegafusion/runtime.py#line=329), in VegaFusionRuntime._import_inline_datasets(self, inline_datasets, inline_dataset_usage)
    327 except TypeError:
    328     # Not supported by Narwhals, try pycapsule interface directly
    329     if hasattr(value, "__arrow_c_stream__"):
--> 330         imported_inline_datasets[name] = Table(value)  # type: ignore[arg-type]
    331     else:
    332         raise

TypeError: Expected Table-like input or dict of arrays or sequence of arrays.

Here's a minimal example to reproduce the error:

import pandas as pd
import altair as alt
alt.data_transformers.disable_max_rows()
alt.data_transformers.enable("vegafusion")
#alt.renderers.enable("jupyterlab")

url = "https://raw.githubusercontent.com/firasm/bits/refs/heads/master/street_trees.csv"

df = pd.read_csv(url)

alt.Chart(df).mark_point().encode(alt.X('count(diameter)'),alt.Y('species_name'))
@firasm
Copy link
Author

firasm commented Jan 26, 2025

FWIW, downgrading to vegafusion 1.6.9 (and vegafusion-python-embed-1.6.9) fixes the issue for me, so potentially this is a result of the breaking changes introduced in 2.0?

@MarcoGorelli
Copy link
Contributor

hi @firasm - this works for me, you probably just need to upgrade your pandas version, it looks like you've got a version which didn't support the pycapsule interface

@firasm
Copy link
Author

firasm commented Jan 27, 2025

That fixed it - thank you!

@firasm firasm closed this as completed Jan 27, 2025
@MarcoGorelli
Copy link
Contributor

@firasm thanks - just for my understanding, which pandas version were you using before?

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