コード例 #1
0
ファイル: dtm_gui.py プロジェクト: humlab/penelope
def plot_tabular(df: pd.DataFrame, opts: ComputeOpts) -> DataGrid:
    renderer = TextRenderer(
        format=',') if not opts.normalize else TextRenderer(format=',.4f')
    grid = DataGrid(
        df,
        base_row_size=30,
        selection_mode="cell",
        editable=False,
        base_column_size=80,
        # layout={'height': '200px'}
        renderers={
            c: renderer
            for c in df.columns if c not in TEMPORAL_GROUP_BY
        },
    )
    grid.transform([{"type": "sort", "columnIndex": 0, "desc": False}])
    grid.auto_fit_params = {"area": "all", "padding": 40, "numCols": 1}
    grid.auto_fit_columns = True
    return grid
コード例 #2
0
ファイル: grid_utility.py プロジェクト: humlab/penelope
def display_grid(data: Union[dict, pd.DataFrame], **opts) -> DataGrid:
    column_formats: dict = opts.get('column_formats', {})
    renderers = {
        c: TextRenderer(format=column_formats[c])
        if c in column_formats else TextRenderer()
        for c in data.columns
    }
    grid = DataGrid(
        data,
        base_row_size=30,
        selection_mode="cell",
        editable=False,
        base_column_size=80,
        # layout={'height': '200px'}
        renderers=renderers,
    )
    grid.transform([{"type": "sort", "columnIndex": 0, "desc": False}])
    grid.auto_fit_params = {"area": "all", "padding": 40, "numCols": 1}
    grid.auto_fit_columns = True
    return grid