-
Notifications
You must be signed in to change notification settings - Fork 786
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
improve feedback to user with "." in column #3451
Comments
Thanks for raising. You will have to escape special characters in Altair or replace them, see https://altair-viz.github.io/user_guide/encodings/index.html#escaping-special-characters-in-column-names |
@mattijn Alright sure - but this should 100% have its own error message. It would be as simple as just checking the column names for special characters and then raising an error if there are any. Would save tons of time for I imagine lots of people who might run in to this |
@mattijn If you don't mind it'd be good to reopen or make a new issue for making an error message for this - would be super useful |
Always open for ideas to improve the user experience, see also #2824 |
Also just making clear the error message should be for all special characters not just "." - thank you for the help! |
If you have a clear approach in mind to improve this, please feel free to contribute. import pandas as pd
import altair as alt
df = pd.DataFrame(data=[
{"type": "Feature", "properties": {"location": "left"}, "geometry": {"type": "Polygon", "coordinates": [[[1.45, 3.75], [1.45, 0], [0, 0], [1.45, 3.75]]]}},
{"type": "Feature", "properties": {"location": "middle-left"}, "geometry": {"type": "Polygon", "coordinates": [[[1.45, 0], [1.45, 3.75], [2.57, 3.75], [2.57, 0], [2.33, 0], [1.45, 0]]]}},
{"type": "Feature", "properties": {"location": "middle-right"}, "geometry": {"type": "Polygon", "coordinates": [[[2.33, 0], [2.33, 2.5], [3.47, 2.5], [3.47, 0], [3.2, 0], [2.57, 0], [2.33, 0]]]}},
{"type": "Feature", "properties": {"location": "right"}, "geometry": {"type": "Polygon", "coordinates": [[[3.2, 0], [3.2, 1.25], [4.32, 1.25], [4.32, 0], [3.47, 0], [3.2, 0]]]}}
])
df alt.Chart(df).mark_geoshape().encode(
alt.Color("properties.location:O").scale(scheme='magma')
).project(type="identity", reflectY=True) |
What happened?
Had a pandas dataframe with columns with "." (without quotes) in name (was using a string of a floating point number as part of a key name). Tried to plot, nothing shows up. 2 hours of debugging later realised that if you truncate the numbers to before the "." then it works fine.
What would you like to happen instead?
Columns should properly plot
P.S. - not 100% if this is an Altair-specific problem or a Vega-lite problem - I have no clue how to replicate 100% accurately there. This should be easily reproducible though anyways.
Which version of Altair are you using?
5.3.0
The text was updated successfully, but these errors were encountered: