Multichem commited on
Commit
fe5cadb
·
verified ·
1 Parent(s): 128eaed

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -13
app.py CHANGED
@@ -12,7 +12,7 @@ import gspread
12
  import gc
13
  import plotly.express as px
14
  import plotly.io as pio
15
- pio.renderers.default='browser'
16
 
17
  @st.cache_resource
18
  def init_conn():
@@ -32,10 +32,12 @@ def init_conn():
32
  }
33
 
34
  gc_con = gspread.service_account_from_dict(credentials, scope)
 
 
35
 
36
- return gc_con
37
 
38
- gcservice_account = init_conn()
39
 
40
  NBA_Data = 'https://docs.google.com/spreadsheets/d/1Yq0vGriWK-bS79e-bD6_u9pqrYE6Yrlbb_wEkmH-ot0/edit#gid=1808117109'
41
 
@@ -45,11 +47,12 @@ percentages_format = {'PG': '{:.2%}', 'SG': '{:.2%}', 'SF': '{:.2%}', 'PF': '{:.
45
  def init_baselines():
46
  sh = gcservice_account.open_by_url(NBA_Data)
47
 
48
- worksheet = sh.worksheet('Gamelog')
49
- raw_display = pd.DataFrame(worksheet.get_values())
50
- raw_display.columns = raw_display.iloc[0]
51
- raw_display = raw_display[1:]
52
- raw_display = raw_display.reset_index(drop=True)
 
53
  gamelog_table = raw_display[raw_display['PLAYER_NAME'] != ""]
54
  gamelog_table = gamelog_table[['PLAYER_NAME', 'POS', 'GAME_ID', 'TEAM_NAME', 'OPP_NAME', 'SEASON_ID', 'GAME_DATE', 'MATCHUP', 'MIN', 'touches', 'PTS', 'FGM', 'FGA', 'FG_PCT', 'FG3M', 'FG3A',
55
  'FG3_PCT', 'FTM', 'FTA', 'FT_PCT', 'reboundChancesOffensive', 'OREB', 'reboundChancesDefensive', 'DREB', 'reboundChancesTotal', 'REB',
@@ -90,11 +93,12 @@ def init_baselines():
90
  'Passes', 'Alt Assists', 'FT Assists', 'Assists', 'Stl', 'Blk', 'Tov', 'PF', 'DD', 'TD', 'Fantasy', 'FD_Fantasy', 'FPPM',
91
  'Rebound%', 'Assists/Pass', 'Touch_per_min', 'Fantasy/Touch', 'FD Fantasy/Touch', 'team_score', 'opp_score', 'spread'], axis=1)
92
 
93
- worksheet = sh.worksheet('Rotations')
94
- raw_display = pd.DataFrame(worksheet.get_values())
95
- raw_display.columns = raw_display.iloc[0]
96
- raw_display = raw_display[1:]
97
- raw_display = raw_display.reset_index(drop=True)
 
98
  rot_table = raw_display[raw_display['Player'] != ""]
99
  rot_table = rot_table[['Player', 'Team', 'PG', 'SG', 'SF', 'PF', 'C', 'Given Pos']]
100
  data_cols = ['PG', 'SG', 'SF', 'PF', 'C']
 
12
  import gc
13
  import plotly.express as px
14
  import plotly.io as pio
15
+ import pymongo
16
 
17
  @st.cache_resource
18
  def init_conn():
 
32
  }
33
 
34
  gc_con = gspread.service_account_from_dict(credentials, scope)
35
+
36
+ client = pymongo.MongoClient("mongodb+srv://multichem:[email protected]/testing_db")
37
 
38
+ return gc_con, client
39
 
40
+ gcservice_account, client = init_conn()
41
 
42
  NBA_Data = 'https://docs.google.com/spreadsheets/d/1Yq0vGriWK-bS79e-bD6_u9pqrYE6Yrlbb_wEkmH-ot0/edit#gid=1808117109'
43
 
 
47
  def init_baselines():
48
  sh = gcservice_account.open_by_url(NBA_Data)
49
 
50
+ db = client["gamelog"]
51
+ collection = db["rotations"]
52
+
53
+ cursor = collection.find() # Finds all documents in the collection
54
+
55
+ raw_display = pd.DataFrame(list(cursor))
56
  gamelog_table = raw_display[raw_display['PLAYER_NAME'] != ""]
57
  gamelog_table = gamelog_table[['PLAYER_NAME', 'POS', 'GAME_ID', 'TEAM_NAME', 'OPP_NAME', 'SEASON_ID', 'GAME_DATE', 'MATCHUP', 'MIN', 'touches', 'PTS', 'FGM', 'FGA', 'FG_PCT', 'FG3M', 'FG3A',
58
  'FG3_PCT', 'FTM', 'FTA', 'FT_PCT', 'reboundChancesOffensive', 'OREB', 'reboundChancesDefensive', 'DREB', 'reboundChancesTotal', 'REB',
 
93
  'Passes', 'Alt Assists', 'FT Assists', 'Assists', 'Stl', 'Blk', 'Tov', 'PF', 'DD', 'TD', 'Fantasy', 'FD_Fantasy', 'FPPM',
94
  'Rebound%', 'Assists/Pass', 'Touch_per_min', 'Fantasy/Touch', 'FD Fantasy/Touch', 'team_score', 'opp_score', 'spread'], axis=1)
95
 
96
+ db = client["testing_db"]
97
+ collection = db["rotations"]
98
+
99
+ cursor = collection.find() # Finds all documents in the collection
100
+
101
+ raw_display = pd.DataFrame(list(cursor))
102
  rot_table = raw_display[raw_display['Player'] != ""]
103
  rot_table = rot_table[['Player', 'Team', 'PG', 'SG', 'SF', 'PF', 'C', 'Given Pos']]
104
  data_cols = ['PG', 'SG', 'SF', 'PF', 'C']