-
Notifications
You must be signed in to change notification settings - Fork 0
/
basketball.py
95 lines (70 loc) · 1.96 KB
/
basketball.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import plotly.graph_objs as go
df = pd.read_excel('NBAmvptracker.xlsx', sheet_name='Sheet1')
external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
stats = ['FG%', '3P%', '2P%', 'FT%', 'PTS']
colors = {
'background': '#ffffff',
'text': '#000000'
}
players = []
for i in df.index:
players.append(df['Player'][i])
print df['Player'][i]
app.layout = html.Div([
html.H1(
children='NBA Most Valuable Player Tracker',
style={
'textAlign': 'center',
'color': colors['text']
}
),
html.Div(
children='A Closer Look at the Top 10 Players in MVP Contention ',
style={
'textAlign': 'center',
'color': colors['text']
}
),
html.Div([
dcc.Dropdown(
id="stat-column",
options=[{'label': i, 'value': i} for i in stats],
value="FG%"
),
dcc.Graph(id='model-graphic')
])
])
@app.callback(
dash.dependencies.Output('model-graphic', 'figure'),
[dash.dependencies.Input('stat-column', 'value')]
)
def update_model(variable_column):
return {
'data': [go.Scatter(
x=players,
y=df[variable_column],
mode='markers',
marker={
'size': 15,
'opacity': 0.5,
'line': {'width': 0.5, 'color': 'white'}
}
)],
'layout': go.Layout(
xaxis={
'title': 'MVP Candidates'
},
yaxis={
'title': variable_column
},
margin={'l': 40, 'b': 40, 't': 10, 'r': 0},
hovermode='closest'
)
}
if __name__ == '__main__':
app.run_server(debug=True)