55import dash_table
66import dash_html_components as html
77import dash_core_components as dcc
8+ from .data import create_dataframe
89from .layout import html_layout
910
1011
@@ -19,13 +20,8 @@ def create_dashboard(server):
1920 ]
2021 )
2122
22- # Prepare a DataFrame
23- df = pd .read_csv ('data/311-calls.csv' , parse_dates = ['created' ])
24- df ['created' ] = df ['created' ].dt .date
25- df .drop (columns = ['incident_zip' ], inplace = True )
26- num_complaints = df ['complaint_type' ].value_counts ()
27- to_remove = num_complaints [num_complaints <= 30 ].index
28- df .replace (to_remove , np .nan , inplace = True )
23+ # Load DataFrame
24+ df = create_dataframe ()
2925
3026 # Custom HTML layout
3127 dash_app .index_string = html_layout
@@ -35,23 +31,21 @@ def create_dashboard(server):
3531 children = [dcc .Graph (
3632 id = 'histogram-graph' ,
3733 figure = {
38- 'data' : [
39- {
40- 'x' : df ['complaint_type' ],
41- 'text' : df ['complaint_type' ],
42- 'customdata' : df ['key' ],
43- 'name' : '311 Calls by region.' ,
44- 'type' : 'histogram'
45- }
46- ],
34+ 'data' : [{
35+ 'x' : df ['complaint_type' ],
36+ 'text' : df ['complaint_type' ],
37+ 'customdata' : df ['key' ],
38+ 'name' : '311 Calls by region.' ,
39+ 'type' : 'histogram'
40+ }],
4741 'layout' : {
4842 'title' : 'NYC 311 Calls category.' ,
4943 'height' : 500 ,
5044 'padding' : 150
5145 }
5246 }),
53- create_data_table (df )
54- ],
47+ create_data_table (df )
48+ ],
5549 id = 'dash-container'
5650 )
5751 return dash_app .server
@@ -68,3 +62,4 @@ def create_data_table(df):
6862 page_size = 300
6963 )
7064 return table
65+
0 commit comments