| Total Complexity | 1 |
| Total Lines | 36 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | import dash |
||
| 2 | import dash_core_components as dcc |
||
| 3 | import dash_html_components as html |
||
| 4 | import pandas as pd |
||
| 5 | |||
| 6 | df = pd.read_csv( |
||
| 7 | 'https://gist.githubusercontent.com/chriddyp/' |
||
| 8 | 'c78bf172206ce24f77d6363a2d754b59/raw/' |
||
| 9 | 'c353e8ef842413cae56ae3920b8fd78468aa4cb2/' |
||
| 10 | 'usa-agricultural-exports-2011.csv') |
||
| 11 | |||
| 12 | |||
| 13 | def generate_table(dataframe, max_rows=10): |
||
| 14 | return html.Table( |
||
| 15 | # Header |
||
| 16 | [html.Tr([html.Th(col) for col in dataframe.columns])] + |
||
| 17 | |||
| 18 | # Body |
||
| 19 | [html.Tr([ |
||
| 20 | html.Td(dataframe.iloc[i][col]) for col in dataframe.columns |
||
| 21 | ]) for i in range(min(len(dataframe), max_rows))] |
||
| 22 | ) |
||
| 23 | |||
| 24 | |||
| 25 | external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css'] |
||
| 26 | |||
| 27 | app = dash.Dash(__name__, external_stylesheets=external_stylesheets) |
||
| 28 | |||
| 29 | app.layout = html.Div(children=[ |
||
| 30 | html.H4(children='US Agriculture Exports (2011)'), |
||
| 31 | generate_table(df) |
||
| 32 | ]) |
||
| 33 | |||
| 34 | if __name__ == '__main__': |
||
| 35 | app.run_server(debug=True) |
||
| 36 |