I am trying to display a table in a jupyter laptop using python and the Bokeh visualization library. I use the following code to display my table in a jupyter laptop, where result is a dataframe:
source = ColumnDataSource(result) columns = [ TableColumn(field="ts", title="Timestamp"), TableColumn(field="bid_qty", title="Bid Quantity"), TableColumn(field="bid_prc", title="Bid Price"), TableColumn(field="ask_prc", title="Ask Price"), TableColumn(field="ask_qty", title="Ask Quantity"), ] data_table = DataTable(source=source, columns=columns, fit_columns=True, width=1300, height=800) show(widgetbox([data_table], sizing_mode = 'scale_both'))
I used to use vform, although now it seems to be depreciated and no longer works as expected. This happened after updating my version of jupyter laptop. Regardless of the fact that I set the width, the column headings do not line up and have a strange coincidence with the table:

This was not before, I was able to get a good table where everything was lined up. Even if I customize the headers, they still don't line up. This does not happen when I save the table as an html file instead of calling show () directly in a Jupyter laptop. What do i need to change? Is there a better way to do this?
Full example
from bokeh.io import show, output_notebook from bokeh.layouts import widgetbox from bokeh.models import ColumnDataSource from bokeh.models.widgets import TableColumn, DataTable import pandas as pd output_notebook() d = {'one' : pd.Series([1., 2., 3.], index=['a', 'b', 'c']), 'two' : pd.Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd'])} df = pd.DataFrame(d) source = ColumnDataSource(df) columns = [ TableColumn(field="one", title="One"), TableColumn(field="two", title=" Two"), ] data_table = DataTable(source=source, columns=columns, fit_columns=True, width=800, height=800) show(widgetbox([data_table], sizing_mode = 'scale_both'))
This works on a system with the following versions:
- Jupyter 4.2.0
- Python 2.7.12 (Anaconda 2.3.0 64 bit)
- Bokeh 0.12.2