当前位置: 首页>>代码示例>>Python>>正文


Python widgets.TableColumn方法代码示例

本文整理汇总了Python中bokeh.models.widgets.TableColumn方法的典型用法代码示例。如果您正苦于以下问题:Python widgets.TableColumn方法的具体用法?Python widgets.TableColumn怎么用?Python widgets.TableColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在bokeh.models.widgets的用法示例。


在下文中一共展示了widgets.TableColumn方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _build_optresult_selector

# 需要导入模块: from bokeh.models import widgets [as 别名]
# 或者: from bokeh.models.widgets import TableColumn [as 别名]
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 
开发者ID:verybadsoldier,项目名称:backtrader_plotting,代码行数:37,代码来源:optbrowser.py

示例2: EpitopeTable

# 需要导入模块: from bokeh.models import widgets [as 别名]
# 或者: from bokeh.models.widgets import TableColumn [as 别名]
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) 
开发者ID:MathOnco,项目名称:NeoPredPipe,代码行数:7,代码来源:NeoPredViz.py

示例3: SummaryTable

# 需要导入模块: from bokeh.models import widgets [as 别名]
# 或者: from bokeh.models.widgets import TableColumn [as 别名]
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) 
开发者ID:MathOnco,项目名称:NeoPredPipe,代码行数:8,代码来源:NeoPredViz.py

示例4: plot_Scatterplot

# 需要导入模块: from bokeh.models import widgets [as 别名]
# 或者: from bokeh.models.widgets import TableColumn [as 别名]
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) 
开发者ID:PatrikHlobil,项目名称:Pandas-Bokeh,代码行数:30,代码来源:make_plots.py

示例5: _create_events_table

# 需要导入模块: from bokeh.models import widgets [as 别名]
# 或者: from bokeh.models.widgets import TableColumn [as 别名]
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,
    ) 
开发者ID:NervanaSystems,项目名称:nlp-architect,代码行数:32,代码来源:absa_solution.py

示例6: _create_examples_table

# 需要导入模块: from bokeh.models import widgets [as 别名]
# 或者: from bokeh.models.widgets import TableColumn [as 别名]
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,
    ) 
开发者ID:NervanaSystems,项目名称:nlp-architect,代码行数:31,代码来源:absa_solution.py

示例7: test_scatterplot

# 需要导入模块: from bokeh.models import widgets [as 别名]
# 或者: from bokeh.models.widgets import TableColumn [as 别名]
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 
开发者ID:PatrikHlobil,项目名称:Pandas-Bokeh,代码行数:45,代码来源:test_PandasBokeh.py


注:本文中的bokeh.models.widgets.TableColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。