Hovertool does not handle spaces or parentheses in column names
See original GitHub issueI’m using bokeh.plotting
with the circle
glyph renderer and noticed that HoverTool
does not seem to handle column names that parentheses or spaces well.
An example from iPython Notebook below:
fake_data = {'ID': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
'Total': [0.0, 20.0, 0.0, 6.0, 8.0, 0.0, 8.0, 5.0, 8.0, 1.0, 2.0],
'Column With Spaces': ['a', 'b', 'c','d', 'e', 'f', 'g', 'h', 'i', 'j', 'k'],
'Column_Without_Spaces': ['a', 'b', 'c','d', 'e', 'f', 'g', 'h', 'i', 'j', 'k'],
'Column_With_Parenthese(s)': ['a', 'b', 'c','d', 'e', 'f', 'g', 'h', 'i', 'j', 'k'],
'Column_Without_Parentheses': ['a', 'b', 'c','d', 'e', 'f', 'g', 'h', 'i', 'j', 'k']
}
df = pd.DataFrame(fake_data)
source = ColumnDataSource(data=df)
hover = HoverTool(
tooltips = [
('ID', '@ID'),
('Total', '@Total'),
('Column With Spaces', '@Column With Spaces'),
('Column_Without_Spaces', '@Column_Without_Spaces'),
('Column_With_Parenthese(s)', '@Column_With_Parenthese(s)'),
('Column_Without_Parentheses', '@Column_Without_Parentheses')
]
)
p = figure(plot_width=400, plot_height=400, title=None, tools=[hover])
p.circle('ID', 'Total', size=10, source=source)
output_notebook()
show(p)
The issues as I see them:
HoverTool
does not flag that column names with parentheses or spaces are problematic- A fair amount of real data may have spaces or parentheses in column names (including ones I analyze at work), and it would be preferable to Bokeh being able to handle these naturally rather than for me to rename all the offending columns.
- I have not exhaustively investigated what other symbols may raise this issue, so there could be many other instances of
HoverTool
not displaying them.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:13 (6 by maintainers)
Top Results From Across the Web
Dataframes with spaces in column names don't work in hover ...
HoloViews is internally escaping columns with spaces in them. If you change the column reference to @{col_1} it should work:
Read more >Using column name in hover tool, passing legend to hover tool?
Can a user use the title (header) of a pandas column data set to label a plot name via hover tool? Also, is...
Read more >Descarregar | PHP Tools for Visual Studio and VS Code by ...
The documentation link the muse hover tool-tip can be enabled or disabled ... Parenthesis of function or method headers on a new line...
Read more >How to write SQL queries with spaces in column names
In SQL Server, we can specify the column name with space in square bracket or parenthesis. Let us understand the concept with some...
Read more >Hover text and formatting in Python - Plotly
If you're not familiar with the structure of plotly figures, you can read the ... The hover_data argument accepts a list of column...
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
@carlshan @moorepants
Bokeh tooltips doesn’t work with space or - in column name after @
fix it by copy ‘column-a’ or ‘column a’ to ‘columna’ by df[‘column-a’] = df[‘columna’]
or you can replace your column with space or - by
df_column = [] for c in data.columns: df_column.append(c.replace(’ ', ‘_’))
data.columns = df_column
I’m not able to get
"@{Column Name}"
to work. Has this changed?