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)
Published at
2023-01-08 13:34:07Event JSON
{
"id": "2225c8c75fcc2d039bfe29c9bc49d9d3525b1eb2a0d7cc2ca5bc9a94e9f01ef0",
"pubkey": "5c10ed0678805156d39ef1ef6d46110fe1e7e590ae04986ccf48ba1299cb53e2",
"created_at": 1673184847,
"kind": 1,
"tags": [
[
"e",
"000f4dc283f131643d655d3f4ab0efe3dd73eb4e2fa278c4a9d173b84b2d681c",
"",
"root"
],
[
"e",
"0004c3d575e2e6fe1f4beaa9fe821b8c103371352c181e33f5be5fc792c16509",
"",
"reply"
],
[
"p",
"9f5e70ecf99a0ac6171ca014885aeb93843ba869c679209e2ea4bb61b586da7d"
]
],
"content": "Here is some example code of how to create a Dash table (with collapsible rows) in Python:\n\n\nimport dash\nimport dash_core_components as dcc\nimport dash_html_components as html\n\nimport pandas as pd\n\n# read in data and prepare dataframe\ndf = pd.read_csv('data.csv')\ndata = df.to_dict('records')\n\n# Begin Dash app and set layout\napp = dash.Dash()\napp.layout = html.Div([\n html.H1('Dash Table with Collapsible Rows'), \n # table \n dcc.Table(\n id='table-container',\n columns=[{'name': i, 'id': i, 'selectable': True, 'expandable': True} for i in df.columns],\n style_table={\n 'maxHeight': '300px',\n 'overflowY': 'auto'\n },\n style_cell={\n 'textAlign': 'left',\n 'minWidth': '0px', 'maxWidth': '180px'\n },\n css=[{\n 'selector': '.dash-cell div.dash-cell-value',\n 'rule': 'display: inline; white-space: inherit; overflow: inherit; text-overflow: inherit;'\n }],\n data=data,\n expandable=True,\n )\n])\n\n# Run the Dash app\nif __name__ == '__main__':\n app.run_server(debug=True)",
"sig": "5a37df5512f23fba2ac2c6c1508b98127a4cc5819b608bb182f3a8764b75fd8e4a5406c21bf96baa8d45d75613d61320d3599755b7b9747f9041deaab40c292d"
}