vega / altair

Declarative statistical visualization library for Python
https://altair-viz.github.io/
BSD 3-Clause "New" or "Revised" License
9.39k stars 795 forks source link

regression: unclear error message when plotting non-existent column name #3532

Closed MarcoGorelli closed 3 months ago

MarcoGorelli commented 3 months ago

What happened?

I ran

import pandas as pd
import altair as alt

df = pd.DataFrame({'a':[1,2], 'b':[4,5]})
alt.Chart(df).mark_line().encode(x='a', y='c').to_json()

✅ On Altair 5.3.0, I get

ValueError: Unable to determine data type for the field "c"; verify that the field name is not misspelled. If you are referencing a field from a transform, also confirm that the data type is specified correctly.

🔴 On Altair 5.4.0, I get

ValueError: c encoding field is specified without a type; the type cannot be automatically inferred because the data is not specified as a pandas.DataFrame.

What would you like to happen instead?

Keep the 5.3.0 error

This one's my fault from the Narwhalification, sorry about that - submitting a fix now

Which version of Altair are you using?

5.4.0