Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,150 +1,14 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
import
|
|
|
|
| 5 |
|
| 6 |
-
|
| 7 |
-
"https://www.googleapis.com/auth/drive"]
|
| 8 |
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
"project_id": "sheets-api-connect-378620",
|
| 12 |
-
"private_key_id": "1005124050c80d085e2c5b344345715978dd9cc9",
|
| 13 |
-
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCtKa01beXwc88R\nnPZVQTNPVQuBnbwoOfc66gW3547ja/UEyIGAF112dt/VqHprRafkKGmlg55jqJNt\na4zceLKV+wTm7vBu7lDISTJfGzCf2TrxQYNqwMKE2LOjI69dBM8u4Dcb4k0wcp9v\ntW1ZzLVVuwTvmrg7JBHjiSaB+x5wxm/r3FOiJDXdlAgFlytzqgcyeZMJVKKBQHyJ\njEGg/1720A0numuOCt71w/2G0bDmijuj1e6tH32MwRWcvRNZ19K9ssyDz2S9p68s\nYDhIxX69OWxwScTIHLY6J2t8txf/XMivL/636fPlDADvBEVTdlT606n8CcKUVQeq\npUVdG+lfAgMBAAECggEAP38SUA7B69eTfRpo658ycOs3Amr0JW4H/bb1rNeAul0K\nZhwd/HnU4E07y81xQmey5kN5ZeNrD5EvqkZvSyMJHV0EEahZStwhjCfnDB/cxyix\nZ+kFhv4y9eK+kFpUAhBy5nX6T0O+2T6WvzAwbmbVsZ+X8kJyPuF9m8ldcPlD0sce\ntj8NwVq1ys52eosqs7zi2vjt+eMcaY393l4ls+vNq8Yf27cfyFw45W45CH/97/Nu\n5AmuzlCOAfFF+z4OC5g4rei4E/Qgpxa7/uom+BVfv9G0DIGW/tU6Sne0+37uoGKt\nW6DzhgtebUtoYkG7ZJ05BTXGp2lwgVcNRoPwnKJDxQKBgQDT5wYPUBDW+FHbvZSp\nd1m1UQuXyerqOTA9smFaM8sr/UraeH85DJPEIEk8qsntMBVMhvD3Pw8uIUeFNMYj\naLmZFObsL+WctepXrVo5NB6RtLB/jZYxiKMatMLUJIYtcKIp+2z/YtKiWcLnwotB\nWdCjVnPTxpkurmF2fWP/eewZ+wKBgQDRMtJg7etjvKyjYNQ5fARnCc+XsI3gkBe1\nX9oeXfhyfZFeBXWnZzN1ITgFHplDznmBdxAyYGiQdbbkdKQSghviUQ0igBvoDMYy\n1rWcy+a17Mj98uyNEfmb3X2cC6WpvOZaGHwg9+GY67BThwI3FqHIbyk6Ko09WlTX\nQpRQjMzU7QKBgAfi1iflu+q0LR+3a3vvFCiaToskmZiD7latd9AKk2ocsBd3Woy9\n+hXXecJHPOKV4oUJlJgvAZqe5HGBqEoTEK0wyPNLSQlO/9ypd+0fEnArwFHO7CMF\nycQprAKHJXM1eOOFFuZeQCaInqdPZy1UcV5Szla4UmUZWkk1m24blHzXAoGBAMcA\nyH4qdbxX9AYrC1dvsSRvgcnzytMvX05LU0uF6tzGtG0zVlub4ahvpEHCfNuy44UT\nxRWW/oFFaWjjyFxO5sWggpUqNuHEnRopg3QXx22SRRTGbN45li/+QAocTkgsiRh1\nqEcYZsO4mPCsQqAy6E2p6RcK+Xa+omxvSnVhq0x1AoGAKr8GdkCl4CF6rieLMAQ7\nLNBuuoYGaHoh8l5E2uOQpzwxVy/nMBcAv+2+KqHEzHryUv1owOi6pMLv7A9mTFoS\n18B0QRLuz5fSOsVnmldfC9fpUc6H8cH1SINZpzajqQA74bPwELJjnzrCnH79TnHG\nJuElxA33rFEjbgbzdyrE768=\n-----END PRIVATE KEY-----\n",
|
| 14 |
-
"client_email": "gspread-connection@sheets-api-connect-378620.iam.gserviceaccount.com",
|
| 15 |
-
"client_id": "106625872877651920064",
|
| 16 |
-
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
| 17 |
-
"token_uri": "https://oauth2.googleapis.com/token",
|
| 18 |
-
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
| 19 |
-
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gspread-connection%40sheets-api-connect-378620.iam.gserviceaccount.com"
|
| 20 |
-
}
|
| 21 |
|
| 22 |
-
#
|
| 23 |
-
|
| 24 |
|
| 25 |
-
# Set Streamlit page config
|
| 26 |
-
st.set_page_config(layout="wide")
|
| 27 |
-
|
| 28 |
-
# Define formats for dataframes
|
| 29 |
-
roo_format = {'Win%': '{:.2%}', 'Top_finish': '{:.2%}', 'Top_5_finish': '{:.2%}', 'Top_10_finish': '{:.2%}',
|
| 30 |
-
'60+%': '{:.2%}', '5x%': '{:.2%}', '6x%': '{:.2%}', '7x%': '{:.2%}', 'Own': '{:.2%}', 'LevX': '{:.2%}'}
|
| 31 |
-
stat_format = {'Odds%': '{:.2%}'}
|
| 32 |
-
table_format = {'Odds': '{:.2%}'}
|
| 33 |
-
|
| 34 |
-
# Define sheet URLs
|
| 35 |
-
sheet_urls = {
|
| 36 |
-
'csgo_overall': 'CSGO_Overall_Proj',
|
| 37 |
-
'csgo_rpl': 'CSGO_RPL_Proj',
|
| 38 |
-
'csgo_neutral': 'CSGO_Neutral_Proj',
|
| 39 |
-
'csgo_wins': 'CSGO_Win_Proj',
|
| 40 |
-
'csgo_losses': 'CSGO_Loss_Proj',
|
| 41 |
-
'overall_odds': 'https://docs.google.com/spreadsheets/d/1aLVN4izjSuqZGRyz73Kip6U1q3rubh6v9GrckgEqbfs/edit?pli=1#gid=1545712013',
|
| 42 |
-
'RPL_odds': 'https://docs.google.com/spreadsheets/d/1aLVN4izjSuqZGRyz73Kip6U1q3rubh6v9GrckgEqbfs/edit?pli=1#gid=1545712013',
|
| 43 |
-
'csgo_bo1': 'https://docs.google.com/spreadsheets/d/1aLVN4izjSuqZGRyz73Kip6U1q3rubh6v9GrckgEqbfs/edit?pli=1#gid=1545712013',
|
| 44 |
-
'two_map': 'https://docs.google.com/spreadsheets/d/1aLVN4izjSuqZGRyz73Kip6U1q3rubh6v9GrckgEqbfs/edit?pli=1#gid=1545712013',
|
| 45 |
-
'csgo_bo3': 'https://docs.google.com/spreadsheets/d/1aLVN4izjSuqZGRyz73Kip6U1q3rubh6v9GrckgEqbfs/edit?pli=1#gid=1545712013',
|
| 46 |
-
'csgo_bo5': 'https://docs.google.com/spreadsheets/d/1aLVN4izjSuqZGRyz73Kip6U1q3rubh6v9GrckgEqbfs/edit?pli=1#gid=1545712013',
|
| 47 |
-
'player_baselines': 'https://docs.google.com/spreadsheets/d/1aLVN4izjSuqZGRyz73Kip6U1q3rubh6v9GrckgEqbfs/edit?pli=1#gid=1545712013'
|
| 48 |
-
}
|
| 49 |
-
|
| 50 |
-
# Define function to load data from Google Sheets
|
| 51 |
-
@st.cache_data
|
| 52 |
-
def load_data(sheet_name, worksheet_name=None):
|
| 53 |
-
try:
|
| 54 |
-
sh = gc.open_by_url(sheet_name)
|
| 55 |
-
worksheet = sh.get_worksheet(0) if not worksheet_name else sh.worksheet(worksheet_name)
|
| 56 |
-
df = pd.DataFrame(worksheet.get_all_records())
|
| 57 |
-
return df
|
| 58 |
-
except Exception as e:
|
| 59 |
-
st.error(f"Error loading data: {e}")
|
| 60 |
-
return pd.DataFrame()
|
| 61 |
-
|
| 62 |
-
# Define function to convert dataframe to CSV
|
| 63 |
-
def convert_df_to_csv(df):
|
| 64 |
-
return df.to_csv().encode('utf-8')
|
| 65 |
-
|
| 66 |
-
# Load initial data
|
| 67 |
-
hold_display = load_data(sheet_urls['csgo_overall'])
|
| 68 |
-
|
| 69 |
-
# Define tabs for the app
|
| 70 |
-
tab1, tab2, tab3, tab4, tab5 = st.tabs(["CSGO Odds Tables", "CSGO Range of Outcomes", "CSGO Player Stat Projections", "CSGO Slate Baselines", '2-map Projections'])
|
| 71 |
-
|
| 72 |
-
with tab1:
|
| 73 |
-
if st.button("Reset Data", key='reset4'):
|
| 74 |
-
st.cache_data.clear()
|
| 75 |
-
|
| 76 |
-
odds_choice = st.radio("What table would you like to display?", ('Overall', 'RPL'), key='odds_table')
|
| 77 |
-
if odds_choice == 'Overall':
|
| 78 |
-
hold_display = load_data(sheet_urls['overall_odds'], 'Overall_Vegas')
|
| 79 |
-
elif odds_choice == 'RPL':
|
| 80 |
-
hold_display = load_data(sheet_urls['RPL_odds'], 'RPL_Vegas')
|
| 81 |
-
|
| 82 |
-
hold_display['Odds'] = hold_display['Odds'].str.replace('%', '').astype(float)/100
|
| 83 |
-
display = hold_display.set_index('Team')
|
| 84 |
-
st.dataframe(display.style.background_gradient(cmap='RdYlGn').format(table_format, precision=2), use_container_width=True)
|
| 85 |
-
st.download_button(label="Export Tables", data=convert_df_to_csv(display), file_name='CSGO_Odds_Tables_export.csv', mime='text/csv')
|
| 86 |
-
|
| 87 |
-
with tab2:
|
| 88 |
-
if st.button("Reset Data", key='reset1'):
|
| 89 |
-
st.cache_data.clear()
|
| 90 |
-
|
| 91 |
-
model_choice = st.radio("What table would you like to display?", ('Overall', 'RPL', 'Neutral', 'Wins', 'Losses'), key='roo_table')
|
| 92 |
-
team_var1 = st.multiselect('View specific team?', options=hold_display['Team'].unique(), key='roo_teamvar')
|
| 93 |
-
|
| 94 |
-
if model_choice == 'Overall':
|
| 95 |
-
hold_display = load_data(sheet_urls['csgo_overall'])
|
| 96 |
-
elif model_choice == 'RPL':
|
| 97 |
-
hold_display = load_data(sheet_urls['csgo_rpl'])
|
| 98 |
-
elif model_choice == 'Neutral':
|
| 99 |
-
hold_display = load_data(sheet_urls['csgo_neutral'])
|
| 100 |
-
elif model_choice == 'Wins':
|
| 101 |
-
hold_display = load_data(sheet_urls['csgo_wins'])
|
| 102 |
-
elif model_choice == 'Losses':
|
| 103 |
-
hold_display = load_data(sheet_urls['csgo_losses'])
|
| 104 |
-
|
| 105 |
-
hold_display['Own'] = hold_display['Own'] / 100
|
| 106 |
-
display = hold_display.set_index('Player')
|
| 107 |
-
export_display = display.copy()
|
| 108 |
-
export_display['Own'] = export_display['Own'] * 100
|
| 109 |
-
export_display['Position'] = "FLEX"
|
| 110 |
-
|
| 111 |
-
if team_var1:
|
| 112 |
-
display = display[display['Team'].isin(team_var1)]
|
| 113 |
-
|
| 114 |
-
st.dataframe(display.style.background_gradient(cmap='RdYlGn').format(roo_format, precision=2), use_container_width=True)
|
| 115 |
-
st.download_button(label="Export Range of Outcomes", data=convert_df_to_csv(export_display), file_name='CSGO_ROO_export.csv', mime='text/csv')
|
| 116 |
-
|
| 117 |
-
with tab3:
|
| 118 |
-
if st.button("Reset Data", key='reset2'):
|
| 119 |
-
st.cache_data.clear()
|
| 120 |
-
|
| 121 |
-
gametype_choice = st.radio("What format are the games being played?", ('Best of 1', 'Best of 3', 'Best of 5'), key='player_stats')
|
| 122 |
-
team_var2 = st.multiselect('View specific team?', options=hold_display['Team'].unique(), key='stat_teamvar')
|
| 123 |
-
|
| 124 |
-
if gametype_choice == 'Best of 1':
|
| 125 |
-
hold_display = load_data(sheet_urls['csgo_bo1'], 'Overall_BO1_Projections')
|
| 126 |
-
elif gametype_choice == 'Best of 3':
|
| 127 |
-
hold_display = load_data(sheet_urls['csgo_bo3'], 'Overall_BO3_Projections')
|
| 128 |
-
elif gametype_choice == 'Best of 5':
|
| 129 |
-
hold_display = load_data(sheet_urls['csgo_bo5'], 'Overall_BO5_Projections')
|
| 130 |
-
|
| 131 |
-
display = hold_display.set_index('Player')
|
| 132 |
-
|
| 133 |
-
if team_var2:
|
| 134 |
-
display = display[display['Team'].isin(team_var2)]
|
| 135 |
-
|
| 136 |
-
st.dataframe(display.style.background_gradient(cmap='RdYlGn').format(stat_format, precision=2), use_container_width=True)
|
| 137 |
-
st.download_button(label="Export Projections", data=convert_df_to_csv(display), file_name='CSGO_Projections_export.csv', mime='text/csv')
|
| 138 |
-
|
| 139 |
-
with tab4:
|
| 140 |
-
if st.button("Reset Data", key='reset3'):
|
| 141 |
-
st.cache_data.clear()
|
| 142 |
-
|
| 143 |
-
hold_display = load_data(sheet_urls['player_baselines'], 'Player_Data')
|
| 144 |
-
display = hold_display.set_index('Player')
|
| 145 |
-
st.dataframe(display.style.background_gradient(cmap='RdYlGn').format(precision=2), use_container_width=True)
|
| 146 |
-
st.download_button(label="Export Baselines", data=convert_df_to_csv(display), file_name='CSGO_Baselines_export.csv', mime='text/csv')
|
| 147 |
-
|
| 148 |
-
with tab5:
|
| 149 |
-
if st.button("Reset Data", key='reset5'):
|
| 150 |
-
st.cache_data.clear()
|
|
|
|
| 1 |
+
from parsebets import *
|
| 2 |
+
from iteratenba import *
|
| 3 |
+
from iteratenfl import *
|
| 4 |
+
from createnbascore import *
|
| 5 |
+
from createnflscore import *
|
| 6 |
|
| 7 |
+
bet_dicts = Create_Current_Bet_Dicts('Rebounds')
|
|
|
|
| 8 |
|
| 9 |
+
nba = Create_NBA_Score(bet_dicts)
|
| 10 |
+
print(nba)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
#test = Create_NBA_Score(bet_dicts)
|
| 13 |
+
#print(test)
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|