build_dashboard / app.py
mZichert's picture
Update app.py
aff437f verified
raw
history blame
2.14 kB
import pandas as pd
import panel as pn
import numpy as np
from bokeh.models.widgets.tables import NumberFormatter, BooleanFormatter
pn.extension("tabulator")
### Beispiel DataFrame
df = pd.read_pickle(f"cossims_plural_slicewidth=1.pkl")
if "boson" in df.index:
df = df.drop("boson")
if "bosons" in df.index:
df = df.drop("bosons")
if "boson_s" in df.index:
df = df.drop("boson_s")
df["sum"] = df.sum(axis=1)
df = df.loc[:, 1948:] #1948
#df = df.fillna(0).round(3)
df = df.sort_values("sum", ascending=False)
df = df.head(20)
df.index.name = "token"
outpath = "../results/bosons/cossims_plural_bosons.html"
### functionality
#tabulator_formatters = {"token" : {"title": "token", "type" : "textarea"}} # Formatiert die Zellen
cell_formatters = {col : NumberFormatter(format='0.000') for col in df.columns} # Formatiert die Zellen
header_filters={'token': {'type': 'input', 'func': 'like', 'placeholder': 'search'}} # Für Suche, etc.
### style
theme = "modern" # 'default', 'site', 'simple', 'midnight', 'modern', 'bootstrap', 'bootstrap4', 'materialize', 'bulma', 'semantic-ui', or 'fast'
page_size = 50 # Number of rows
page = 1 # Start on page x
#configuration={"rowHeight" : 10*24}
#widths = {'index' : 40} or {'index': '5%'}
#frozen_rows = list
#frozen_columns = list
tabs = pn.widgets.Tabulator(
df,
### functionality
formatters= cell_formatters, #tabulator_formatters,
header_filters = header_filters,
selectable="toggle",
### style
theme = theme,
page_size = page_size,
page = page,
frozen_columns = {"token" : "left", "sum" : "right"}, # Must give width, otherwise doesn't work!
width=1800,
height=950,
#frozen_rows = [1],
#widths
#configuration = configuration,
### other
disabled = True # Whether the cells are editable
)
ACCENT = "teal"
pn.template.FastListTemplate(
#title="Wind Turbine Dashboard",
#sidebar=[image, t_manu, p_year],
#main=[pn.Column(indicators, tabs, sizing_mode="stretch_both")],
main=[pn.Column(tabs, sizing_mode="stretch_both")],
#main_layout=None,
accent=ACCENT,
).servable()