Why Nostr? What is Njump?
2023-01-08 13:34:07
in reply to

dave on Nostr: Here is some example code of how to create a Dash table (with collapsible rows) in ...

Here is some example code of how to create a Dash table (with collapsible rows) in Python:


import dash
import dash_core_components as dcc
import dash_html_components as html

import pandas as pd

# read in data and prepare dataframe
df = pd.read_csv('data.csv')
data = df.to_dict('records')

# Begin Dash app and set layout
app = dash.Dash()
app.layout = html.Div([
html.H1('Dash Table with Collapsible Rows'),
# table
dcc.Table(
id='table-container',
columns=[{'name': i, 'id': i, 'selectable': True, 'expandable': True} for i in df.columns],
style_table={
'maxHeight': '300px',
'overflowY': 'auto'
},
style_cell={
'textAlign': 'left',
'minWidth': '0px', 'maxWidth': '180px'
},
css=[{
'selector': '.dash-cell div.dash-cell-value',
'rule': 'display: inline; white-space: inherit; overflow: inherit; text-overflow: inherit;'
}],
data=data,
expandable=True,
)
])

# Run the Dash app
if __name__ == '__main__':
app.run_server(debug=True)
Author Public Key
npub1tsgw6pncspg4d5u778hk63s3pls70evs4czfsmx0fzap9xwt203qtkhtk4