【发布时间】:2020-02-13 19:35:32
【问题描述】:
我想创建第二个数据框,然后在一个页面上显示两个表格。现在只显示一个。看起来 dash_bootstrap_components 可以让我分割屏幕,但我找不到包含多个表的示例
import dash
import dash_html_components as html
import pandas as pd
#would like to add a second dataframe here
df1 = pd.read_sas('C:\PY_DASH\file1.sas7bdat', format = 'sas7bdat', encoding='utf-8' )
def generate_table(dataframe, max_rows=7):
return html.Table(
# Header
[html.Tr([html.Th(col) for col in dataframe.columns])] +
# Body
[html.Tr([
html.Td(dataframe.iloc[i][col]) for col in dataframe.columns
]) for i in range(min(len(dataframe), max_rows))]
)
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
#I would like to add the second table here
app.layout = html.Div(children=[
html.H1(children='QA Test: Test 0-1: Output Files Record Count Comparison'),
generate_table(df1)
])
if __name__ == '__main__':
app.run_server(debug=True, port=8000)
【问题讨论】:
标签: python plotly-dash