Javascript error when plotting a column with special characters
See original GitHub issueThe following code throws an error (tested with Altair 2.0.1):
import pandas
import altair
df = pandas.DataFrame({"A column name with 'quotes'" : [1, 2, 3, 4], "A column name without quotes" : [5, 6, 7, 8]})
altair.Chart(df).mark_bar().encode(
altair.X(df.columns[0], bin=True),
y='count()',
)
It fails with the error:
Javascript Error: Access path missing closing bracket: A column name with 'quotes'. This usually means there's a typo in your chart specification. See the JavaScript console for the full traceback.
This does not happen when using a column name without quotes (e.g., if I use df.columns[1]
instead of df.columns[0]
). If I put only one quote instead of two, the error is different:
Javascript Error: Access path missing closing quote: A column name with 'quotes. This usually means there's a typo in your chart specification. See the JavaScript console for the full traceback.
Issue Analytics
- State:
- Created 5 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
how to translate special characters in Javascript - Stack Overflow
From your link I see this. let dataString = `Lot ID,Wafer_ID,Probe Count,Unit Number,X,Y,Head Number,Site Number,Die Pass/Fail,Hard Bin No ...
Read more >Errors using special characters in Access databases - Office
Lists the special characters to avoid using when you work with the database object names or the field names in all versions of...
Read more >Appearance of Grouped graphs - GraphPad Prism 9 User Guide
Select a data set from the list, and choose the symbols, lines, and error bars ... If you choose to plot your data...
Read more >Visualization: Column Chart - Google Developers
Overview. A column chart is a vertical bar chart rendered in the browser using SVG or VML, whichever is appropriate for the user's...
Read more >[Solved]-Unknown characters in column name-Pandas,Python
[Solved]-Unknown characters in column name-Pandas,Python ... You can pass encoding='utf-8' to read_csv as a kwarg so it decodes the BOM correctly. ... This...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Because the escaped version of the field name does not match the pandas column name, Altair cannot infer the type of the column – so you’ll have to specify the type explicitly (just as you do when passing data by URL rather than by dataframe):
I don’t think Altair should automatically escape quotes: the reason they need to be escaped is that they have special meaning within field strings when not escaped, and I would not want Altair to prevent that use.
I think it would be worth raising an appropriate warning when single quotes, double quotes, square brackets, dots, or back-slashes are used.