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

Expected Table-like input error when creating an altair chart #559

Open
samesand opened this issue Feb 13, 2025 · 3 comments
Open

Expected Table-like input error when creating an altair chart #559

samesand opened this issue Feb 13, 2025 · 3 comments

Comments

@samesand
Copy link

Altair 5.5.0
VegaFusion 2.0.1

I'm trying to create charts using the vegafusion transformer, but I get the following error:
TypeError: Expected Table-like input or dict of arrays or sequence of arrays.

This code generates the error:
import pandas as pd
import altair as alt
chart_data = pd.DataFrame([1,2,3,4,5],columns=['y'])
alt.Chart(chart_data).mark_bar().encode(y='y')

I have a different computer with the same versions of Python, Altair and VegaFusion where this code works.

So far, I have tried to uninstall and reinstall Altair, VegaFusion and Python without success.

@dangotbanned dangotbanned marked this as a duplicate of vega/altair#3804 Feb 16, 2025
@MarcoGorelli
Copy link
Contributor

Hi can you show the full error message please

@samesand
Copy link
Author


TypeError Traceback (most recent call last)
File c:\Users\e193645\AppData\Local\Programs\Python\Python313\Lib\site-packages\vegafusion\runtime.py:326, in VegaFusionRuntime._import_inline_datasets(self, inline_datasets, inline_dataset_usage)
324 df_nw = df_nw.select(columns)
--> 326 imported_inline_datasets[name] = Table(df_nw) # type: ignore[arg-type]
327 except TypeError:
328 # Not supported by Narwhals, try pycapsule interface directly

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

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last)
File ~\AppData\Roaming\Python\Python313\site-packages\IPython\core\formatters.py:1036, in MimeBundleFormatter.call(self, obj, include, exclude)
1033 method = get_real_method(obj, self.print_method)
1035 if method is not None:
-> 1036 return method(include=include, exclude=exclude)
1037 return None
1038 else:

File c:\Users\e193645\AppData\Local\Programs\Python\Python313\Lib\site-packages\altair\vegalite\v5\api.py:3682, in TopLevelMixin.repr_mimebundle(self, *args, **kwds)
3680 else:
3681 if renderer := renderers.get():
-> 3682 return renderer(dct)

File c:\Users\e193645\AppData\Local\Programs\Python\Python313\Lib\site-packages\altair\utils\display.py:232, in HTMLRenderer.call(self, spec, **metadata)
230 kwargs = self.kwargs.copy()
231 kwargs.update(**metadata, output_div=self.output_div)
--> 232 return spec_to_mimebundle(spec, format="html", **kwargs)

File c:\Users\e193645\AppData\Local\Programs\Python\Python313\Lib\site-packages\altair\utils\mimebundle.py:129, in spec_to_mimebundle(spec, format, mode, vega_version, vegaembed_version, vegalite_version, embed_options, engine, **kwargs)
127 internal_mode: Literal["vega-lite", "vega"] = mode
128 if using_vegafusion():
--> 129 spec = compile_with_vegafusion(spec)
130 internal_mode = "vega"
132 # Default to the embed options set by alt.renderers.set_embed_options

File c:\Users\e193645\AppData\Local\Programs\Python\Python313\Lib\site-packages\altair\utils_vegafusion_data.py:273, in compile_with_vegafusion(vegalite_spec)
271 # Pre-evaluate transforms in vega spec with vegafusion
272 row_limit = data_transformers.options.get("max_rows", None)
--> 273 transformed_vega_spec, warnings = vf.runtime.pre_transform_spec(
274 vega_spec,
275 vf.get_local_tz(),
276 inline_datasets=inline_tables,
277 row_limit=row_limit,
278 )
280 # Check from row limit warning and convert to MaxRowsError
281 handle_row_limit_exceeded(row_limit, warnings)

File c:\Users\e193645\AppData\Local\Programs\Python\Python313\Lib\site-packages\vegafusion\runtime.py:408, in VegaFusionRuntime.pre_transform_spec(self, spec, local_tz, default_input_tz, row_limit, preserve_interactivity, inline_datasets, keep_signals, keep_datasets)
347 """
348 Evaluate supported transforms in an input Vega specification
349
(...)
405 were eligible for pre-transforming
406 """
407 local_tz = local_tz or get_local_tz()
--> 408 imported_inline_dataset = self._import_inline_datasets(
409 inline_datasets, get_inline_column_usage(spec)
410 )
412 new_spec, warnings = self.runtime.pre_transform_spec(
413 spec,
414 local_tz=local_tz,
(...)
420 keep_datasets=parse_variables(keep_datasets),
421 )
423 return new_spec, warnings

File c:\Users\e193645\AppData\Local\Programs\Python\Python313\Lib\site-packages\vegafusion\runtime.py:330, 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.

@MarcoGorelli
Copy link
Contributor

ah thanks - this'll be fixed by #560

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