Python bokeh.models.widgets.TableColumn() Examples
The following are 9
code examples of bokeh.models.widgets.TableColumn().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
bokeh.models.widgets
, or try the search function
.
Example #1
Source File: optbrowser.py From backtrader_plotting with GNU General Public License v3.0 | 6 votes |
def _build_optresult_selector(self, optresults) -> Tuple[DataTable, ColumnDataSource]: # 1. build a dict with all params and all user columns data_dict = defaultdict(list) for optres in optresults: for param_name, _ in optres[0].params._getitems(): param_val = optres[0].params._get(param_name) data_dict[param_name].append(param_val) for usercol_label, usercol_fnc in self._usercolumns.items(): data_dict[usercol_label].append(usercol_fnc(optres)) # 2. build a pandas DataFrame df = DataFrame(data_dict) # 3. now sort and limit result if self._sortcolumn is not None: df = df.sort_values(by=[self._sortcolumn], ascending=self._sortasc) if self._num_result_limit is not None: df = df.head(self._num_result_limit) # 4. build column info for Bokeh table tab_columns = [] for colname in data_dict.keys(): formatter = NumberFormatter(format='0.000') if len(data_dict[colname]) > 0 and isinstance(data_dict[colname][0], int): formatter = StringFormatter() tab_columns.append(TableColumn(field=colname, title=f'{colname}', sortable=False, formatter=formatter)) # TODO: currently table size is hardcoded cds = ColumnDataSource(df) selector = DataTable(source=cds, columns=tab_columns, width=1600, height=150) return selector, cds
Example #2
Source File: NeoPredViz.py From NeoPredPipe with GNU Lesser General Public License v3.0 | 5 votes |
def EpitopeTable(self): Columns = [TableColumn(field=Ci, title=Ci) for Ci in self.neosData.columns] # bokeh columns data_table = DataTable(columns=Columns, source=ColumnDataSource(self.neosData) ,width=1200, height=200) # bokeh table return(data_table)
Example #3
Source File: NeoPredViz.py From NeoPredPipe with GNU Lesser General Public License v3.0 | 5 votes |
def SummaryTable(self): Columns = [TableColumn(field=Ci, title=Ci) for Ci in self.summaryData.columns] # bokeh columns data_table = DataTable(columns=Columns, source=ColumnDataSource(self.summaryData) ,width=1200, height=200) # bokeh table return(data_table)
Example #4
Source File: make_plots.py From Pandas-Bokeh with MIT License | 5 votes |
def plot_Scatterplot(): plotname = inspect.stack()[0][3][5:] pandas_bokeh.output_file(os.path.join(PLOT_DIR, f"{plotname}.html")) df = df_iris() df = df.sample(frac=1) # Create Bokeh-Table with DataFrame: from bokeh.models.widgets import DataTable, TableColumn from bokeh.models import ColumnDataSource data_table = DataTable( columns=[TableColumn(field=Ci, title=Ci) for Ci in df.columns], source=ColumnDataSource(df.head(10)), ) # Create Scatterplot: p_scatter = df.plot_bokeh.scatter( x="petal length (cm)", y="sepal width (cm)", category="species", title="Iris DataSet Visualization", show_figure=False, ) # Combine Div and Scatterplot via grid layout: pandas_bokeh.plot_grid([[data_table, p_scatter]], plot_width=400, plot_height=350)
Example #5
Source File: absa_solution.py From nlp-architect with Apache License 2.0 | 5 votes |
def _create_events_table() -> DataTable: """Utility function for creating and styling the events table.""" formatter = HTMLTemplateFormatter( template=""" <style> .AS_POS {color: #0000FF; font-weight: bold;} .AS_NEG {color: #0000FF; font-weight: bold;} .OP_POS {color: #1aaa0d; font-style: bold;} .OP_NEG {color: #f40000;font-style: bold;} .NEG_POS {font-style: italic;} .NEG_NEG {color: #f40000; font-style: italic;} .INT_POS {color: #1aaa0d; font-style: italic;} .INT_NEG {color: #f40000; font-style: italic;} </style> <%= value %>""" ) columns = [ TableColumn(field="POS_events", title="Positive Examples", formatter=formatter), TableColumn(field="NEG_events", title="Negative Examples", formatter=formatter), ] return DataTable( source=ColumnDataSource(), columns=columns, height=400, index_position=None, width=2110, sortable=False, editable=True, reorderable=False, )
Example #6
Source File: absa_solution.py From nlp-architect with Apache License 2.0 | 5 votes |
def _create_examples_table() -> DataTable: """Utility function for creating and styling the events table.""" formatter = HTMLTemplateFormatter( template=""" <style> .AS {color: #0000FF; font-weight: bold;} .OP {color: #0000FF; font-weight: bold;} </style> <div><%= value %></div>""" ) columns = [ TableColumn( field="Examples", title='<span class="header">Examples</span>', formatter=formatter ) ] empty_source = ColumnDataSource() empty_source.data = {"Examples": []} return DataTable( source=empty_source, columns=columns, height=500, index_position=None, width=1500, sortable=False, editable=False, reorderable=False, header_row=True, )
Example #7
Source File: ui.py From nlp-architect with Apache License 2.0 | 5 votes |
def _create_events_table() -> DataTable: """Utility function for creating and styling the events table.""" formatter = HTMLTemplateFormatter( template=""" <style> .AS_POS {color: #0000FF; font-weight: bold;} .AS_NEG {color: #0000FF; font-weight: bold;} .OP_POS {color: #1aaa0d; font-style: bold;} .OP_NEG {color: #f40000;font-style: bold;} .NEG_POS {font-style: italic;} .NEG_NEG {color: #f40000; font-style: italic;} .INT_POS {color: #1aaa0d; font-style: italic;} .INT_NEG {color: #f40000; font-style: italic;} </style> <%= value %>""" ) columns = [ TableColumn(field="POS_events", title="Positive Examples", formatter=formatter), TableColumn(field="NEG_events", title="Negative Examples", formatter=formatter), ] return DataTable( source=ColumnDataSource(), columns=columns, height=400, index_position=None, width=2110, sortable=False, editable=True, reorderable=False, )
Example #8
Source File: ui.py From nlp-architect with Apache License 2.0 | 5 votes |
def _create_examples_table() -> DataTable: """Utility function for creating and styling the events table.""" formatter = HTMLTemplateFormatter( template=""" <style> .AS {color: #0000FF; font-weight: bold;} .OP {color: #0000FF; font-weight: bold;} </style> <div><%= value %></div>""" ) columns = [ TableColumn( field="Examples", title='<span class="header">Examples</span>', formatter=formatter ) ] empty_source = ColumnDataSource() empty_source.data = {"Examples": []} return DataTable( source=empty_source, columns=columns, height=500, index_position=None, width=1500, sortable=False, editable=False, reorderable=False, header_row=True, )
Example #9
Source File: test_PandasBokeh.py From Pandas-Bokeh with MIT License | 4 votes |
def test_scatterplot(df_iris): "Test for scatterplot" # Create Bokeh-Table with DataFrame: from bokeh.models.widgets import DataTable, TableColumn from bokeh.models import ColumnDataSource data_table = DataTable( columns=[TableColumn(field=Ci, title=Ci) for Ci in df_iris.columns], source=ColumnDataSource(df_iris.head(10)), ) data_table_accessor = DataTable( columns=[TableColumn(field=Ci, title=Ci) for Ci in df_iris.columns], source=ColumnDataSource(df_iris.head(10)), ) # Create Scatterplot: arguments = dict( x="petal length (cm)", y="sepal width (cm)", category="species", title="Iris DataSet Visualization", show_figure=False, ) p_scatter = df_iris.plot_bokeh(kind="scatter", **arguments) p_scatter_accessor = df_iris.plot_bokeh.scatter(**arguments) p_scatter_pandas_backend = df_iris.plot(kind="scatter", **arguments) p_scatter_accessor_pandas_backend = df_iris.plot.scatter(**arguments) # Combine Div and Scatterplot via grid layout: output = pandas_bokeh.plot_grid( [[data_table, p_scatter], [data_table_accessor, p_scatter_accessor]], show_plot=False, return_html=True, ) with open(os.path.join(DIRECTORY, "Plots", "Scatterplot.html"), "w") as f: f.write(output) assert True