Spaces:
Sleeping
Sleeping
James McCool
commited on
Commit
·
02caa74
1
Parent(s):
6bba819
removed use of gspread
Browse files
app.py
CHANGED
|
@@ -42,14 +42,15 @@ def init_conn():
|
|
| 42 |
|
| 43 |
uri = st.secrets['mongo_uri']
|
| 44 |
client = MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=100000)
|
| 45 |
-
|
|
|
|
| 46 |
|
| 47 |
gc = gspread.service_account_from_dict(credentials)
|
| 48 |
gc2 = gspread.service_account_from_dict(credentials2)
|
| 49 |
|
| 50 |
-
return gc, gc2, NFL_Data,
|
| 51 |
|
| 52 |
-
gcservice_account, gcservice_account2, NFL_Data,
|
| 53 |
|
| 54 |
game_format = {'Win%': '{:.2%}', 'Vegas': '{:.2%}', 'Win% Diff': '{:.2%}'}
|
| 55 |
american_format = {'First Inning Lead Percentage': '{:.2%}', 'Fifth Inning Lead Percentage': '{:.2%}'}
|
|
@@ -63,37 +64,44 @@ def calculate_poisson(row):
|
|
| 63 |
|
| 64 |
@st.cache_resource(ttl=600)
|
| 65 |
def init_baselines():
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
raw_display = pd.DataFrame(
|
| 69 |
-
raw_display
|
| 70 |
-
game_model = raw_display.copy()
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
raw_display.
|
| 75 |
-
overall_stats = raw_display
|
| 76 |
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
raw_display.
|
| 80 |
-
prop_trends = raw_display
|
|
|
|
| 81 |
|
| 82 |
-
|
| 83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 84 |
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
raw_display.
|
| 88 |
-
raw_display
|
| 89 |
-
|
| 90 |
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
raw_display.
|
| 94 |
-
pick_frame = raw_display
|
|
|
|
| 95 |
|
| 96 |
-
collection =
|
| 97 |
cursor = collection.find()
|
| 98 |
|
| 99 |
raw_display = pd.DataFrame(list(cursor))
|
|
|
|
| 42 |
|
| 43 |
uri = st.secrets['mongo_uri']
|
| 44 |
client = MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=100000)
|
| 45 |
+
dfs_db = client["NFL_Database"]
|
| 46 |
+
props_db = client["Props_DB"]
|
| 47 |
|
| 48 |
gc = gspread.service_account_from_dict(credentials)
|
| 49 |
gc2 = gspread.service_account_from_dict(credentials2)
|
| 50 |
|
| 51 |
+
return gc, gc2, NFL_Data, props_db, dfs_db
|
| 52 |
|
| 53 |
+
gcservice_account, gcservice_account2, NFL_Data, props_db, dfs_db = init_conn()
|
| 54 |
|
| 55 |
game_format = {'Win%': '{:.2%}', 'Vegas': '{:.2%}', 'Win% Diff': '{:.2%}'}
|
| 56 |
american_format = {'First Inning Lead Percentage': '{:.2%}', 'Fifth Inning Lead Percentage': '{:.2%}'}
|
|
|
|
| 64 |
|
| 65 |
@st.cache_resource(ttl=600)
|
| 66 |
def init_baselines():
|
| 67 |
+
collection = dfs_db["Game_Betting_Model"]
|
| 68 |
+
cursor = collection.find()
|
| 69 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 70 |
+
game_model = raw_display[['Team', 'Opp', 'Win%', 'Vegas', 'Win% Diff', 'Win Line', 'Vegas Line', 'Line Diff', 'PD Spread', 'Vegas Spread', 'Spread Diff']]
|
|
|
|
| 71 |
|
| 72 |
+
collection = dfs_db["Player_Stats"]
|
| 73 |
+
cursor = collection.find()
|
| 74 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 75 |
+
overall_stats = raw_display[['Player', 'Position', 'Team', 'Opp', 'rush_att', 'rec', 'dropbacks', 'rush_yards', 'rush_tds', 'rec_yards', 'rec_tds', 'pass_att', 'pass_yards', 'pass_tds', 'PPR', 'Half_PPR']]
|
| 76 |
|
| 77 |
+
collection = dfs_db["Prop_Trends"]
|
| 78 |
+
cursor = collection.find()
|
| 79 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 80 |
+
prop_trends = raw_display[['Player', 'over_prop', 'over_line', 'under_prop', 'under_line', 'book', 'prop_type', 'No Vig', 'Team', 'L3 Success', 'L6_Success', 'L10_success', 'L6 Avg', 'Projection',
|
| 81 |
+
'Proj Diff', 'Implied Over', 'Trending Over', 'Over Edge', 'Implied Under', 'Trending Under', 'Under Edge']]
|
| 82 |
|
| 83 |
+
collection = dfs_db["DK_NFL_ROO"]
|
| 84 |
+
cursor = collection.find()
|
| 85 |
+
|
| 86 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 87 |
+
raw_display = raw_display[['Player', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%',
|
| 88 |
+
'Own', 'Small_Field_Own', 'Large_Field_Own', 'Cash_Field_Own', 'CPT_Own', 'LevX', 'version', 'slate', 'timestamp', 'player_id', 'site']]
|
| 89 |
+
load_display = raw_display[raw_display['Position'] != 'K']
|
| 90 |
+
timestamp = load_display['timestamp'][0]
|
| 91 |
|
| 92 |
+
collection = dfs_db["Prop_Trends"]
|
| 93 |
+
cursor = collection.find()
|
| 94 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 95 |
+
prop_frame = raw_display[['Player', 'over_prop', 'over_line', 'under_prop', 'under_line', 'book', 'prop_type', 'No Vig', 'Team', 'L3 Success', 'L6_Success', 'L10_success', 'L6 Avg', 'Projection',
|
| 96 |
+
'Proj Diff', 'Implied Over', 'Trending Over', 'Over Edge', 'Implied Under', 'Trending Under', 'Under Edge']]
|
| 97 |
|
| 98 |
+
collection = dfs_db['Pick6_ingest']
|
| 99 |
+
cursor = collection.find()
|
| 100 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 101 |
+
pick_frame = raw_display[['Player', 'over_prop', 'over_line', 'under_prop', 'under_line', 'book', 'prop_type', 'No Vig', 'Team', 'L3 Success', 'L6_Success', 'L10_success', 'L6 Avg', 'Projection',
|
| 102 |
+
'Proj Diff', 'Implied Over', 'Trending Over', 'Over Edge', 'Implied Under', 'Trending Under', 'Under Edge', 'last_name', 'P6_name', 'Full_name']]
|
| 103 |
|
| 104 |
+
collection = props_db["NFL_Props"]
|
| 105 |
cursor = collection.find()
|
| 106 |
|
| 107 |
raw_display = pd.DataFrame(list(cursor))
|