question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hovertool does not handle spaces or parentheses in column names

See original GitHub issue

I’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)
screenshot 2016-07-12 14 16 28

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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:13 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
asukulcommented, Apr 11, 2017

@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

2reactions
moorepantscommented, Apr 5, 2017

I’m not able to get "@{Column Name}" to work. Has this changed?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found