File size: 23,135 Bytes
eb17727
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
280c1f9
eb17727
 
 
280c1f9
eb17727
c276129
eb17727
 
 
 
280c1f9
6b1ef5e
280c1f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6b1ef5e
cc95c78
280c1f9
eb17727
6b1ef5e
280c1f9
 
 
1b37964
d9ad3e8
 
 
 
6b1ef5e
280c1f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279ff8e
3af6f82
 
1b37964
6b1ef5e
280c1f9
 
 
c276129
d9ad3e8
eb17727
96889df
573fb85
96889df
280c1f9
96889df
 
 
 
 
 
280c1f9
96889df
 
 
 
 
 
573fb85
 
 
280c1f9
573fb85
 
 
 
 
 
280c1f9
573fb85
 
 
 
 
 
c276129
 
 
 
eb17727
 
 
 
d9ad3e8
29ab7c3
 
56ce0fe
 
1208fc7
eb17727
96889df
 
 
 
 
 
 
 
 
 
 
 
 
734367c
96889df
 
 
 
 
 
 
 
 
 
 
280c1f9
96889df
 
280c1f9
96889df
 
 
 
 
 
 
 
 
 
 
 
6919d54
280c1f9
c276129
96889df
 
 
 
 
280c1f9
 
96889df
 
 
 
a32c316
96889df
 
 
 
280c1f9
 
96889df
 
 
 
0713583
96889df
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a32c316
96889df
 
 
 
 
 
 
 
 
 
 
 
777e424
280c1f9
573fb85
96889df
 
 
 
 
 
 
 
 
 
280c1f9
96889df
 
280c1f9
96889df
 
 
 
 
 
280c1f9
96889df
 
 
 
573fb85
96889df
 
280c1f9
 
96889df
573fb85
 
280c1f9
573fb85
a781a50
96889df
 
 
573fb85
96889df
 
280c1f9
 
96889df
573fb85
 
280c1f9
573fb85
6b1ef5e
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
import streamlit as st
st.set_page_config(layout="wide")

for name in dir():
    if not name.startswith('_'):
        del globals()[name]

import numpy as np
import pandas as pd
import streamlit as st
import gspread
import gc

@st.cache_resource
def init_conn():
        scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive']

        credentials = {
          "type": "service_account",
          "project_id": "model-sheets-connect",
          "private_key_id": "0e0bc2fdef04e771172fe5807392b9d6639d945e",
          "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDiu1v/e6KBKOcK\ncx0KQ23nZK3ZVvADYy8u/RUn/EDI82QKxTd/DizRLIV81JiNQxDJXSzgkbwKYEDm\n48E8zGvupU8+Nk76xNPakrQKy2Y8+VJlq5psBtGchJTuUSHcXU5Mg2JhQsB376PJ\nsCw552K6Pw8fpeMDJDZuxpKSkaJR6k9G5Dhf5q8HDXnC5Rh/PRFuKJ2GGRpX7n+2\nhT/sCax0J8jfdTy/MDGiDfJqfQrOPrMKELtsGHR9Iv6F4vKiDqXpKfqH+02E9ptz\nBk+MNcbZ3m90M8ShfRu28ebebsASfarNMzc3dk7tb3utHOGXKCf4tF8yYKo7x8BZ\noO9X4gSfAgMBAAECggEAU8ByyMpSKlTCF32TJhXnVJi/kS+IhC/Qn5JUDMuk4LXr\naAEWsWO6kV/ZRVXArjmuSzuUVrXumISapM9Ps5Ytbl95CJmGDiLDwRL815nvv6k3\nUyAS8EGKjz74RpoIoH6E7EWCAzxlnUgTn+5oP9Flije97epYk3H+e2f1f5e1Nn1d\nYNe8U+1HqJgILcxA1TAUsARBfoD7+K3z/8DVPHI8IpzAh6kTHqhqC23Rram4XoQ6\nzj/ZdVBjvnKuazETfsD+Vl3jGLQA8cKQVV70xdz3xwLcNeHsbPbpGBpZUoF73c65\nkAXOrjYl0JD5yAk+hmYhXr6H9c6z5AieuZGDrhmlFQKBgQDzV6LRXmjn4854DP/J\nI82oX2GcI4eioDZPRukhiQLzYerMQBmyqZIRC+/LTCAhYQSjNgMa+ZKyvLqv48M0\n/x398op/+n3xTs+8L49SPI48/iV+mnH7k0WI/ycd4OOKh8rrmhl/0EWb9iitwJYe\nMjTV/QxNEpPBEXfR1/mvrN/lVQKBgQDuhomOxUhWVRVH6x03slmyRBn0Oiw4MW+r\nrt1hlNgtVmTc5Mu+4G0USMZwYuOB7F8xG4Foc7rIlwS7Ic83jMJxemtqAelwOLdV\nXRLrLWJfX8+O1z/UE15l2q3SUEnQ4esPHbQnZowHLm0mdL14qSVMl1mu1XfsoZ3z\nJZTQb48CIwKBgEWbzQRtKD8lKDupJEYqSrseRbK/ax43DDITS77/DWwHl33D3FYC\nMblUm8ygwxQpR4VUfwDpYXBlklWcJovzamXpSnsfcYVkkQH47NuOXPXPkXQsw+w+\nDYcJzeu7F/vZqk9I7oBkWHUrrik9zPNoUzrfPvSRGtkAoTDSwibhoc5dAoGBAMHE\nK0T/ANeZQLNuzQps6S7G4eqjwz5W8qeeYxsdZkvWThOgDd/ewt3ijMnJm5X05hOn\ni4XF1euTuvUl7wbqYx76Wv3/1ZojiNNgy7ie4rYlyB/6vlBS97F4ZxJdxMlabbCW\n6b3EMWa4EVVXKoA1sCY7IVDE+yoQ1JYsZmq45YzPAoGBANWWHuVueFGZRDZlkNlK\nh5OmySmA0NdNug3G1upaTthyaTZ+CxGliwBqMHAwpkIRPwxUJpUwBTSEGztGTAxs\nWsUOVWlD2/1JaKSmHE8JbNg6sxLilcG6WEDzxjC5dLL1OrGOXj9WhC9KX3sq6qb6\nF/j9eUXfXjAlb042MphoF3ZC\n-----END PRIVATE KEY-----\n",
          "client_email": "[email protected]",
          "client_id": "100369174533302798535",
          "auth_uri": "https://accounts.google.com/o/oauth2/auth",
          "token_uri": "https://oauth2.googleapis.com/token",
          "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
          "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gspread-connection%40model-sheets-connect.iam.gserviceaccount.com"
        }

        gc_con = gspread.service_account_from_dict(credentials, scope)
      
        return gc_con

gcservice_account = init_conn()

NBA_Data = 'https://docs.google.com/spreadsheets/d/1Yq0vGriWK-bS79e-bD6_u9pqrYE6Yrlbb_wEkmH-ot0/edit#gid=1808117109'

@st.cache_resource(ttl = 600)
def init_baselines():
    sh = gcservice_account.open_by_url(NBA_Data)
    
    worksheet = sh.worksheet('Gamelog')
    raw_display = pd.DataFrame(worksheet.get_values())
    raw_display.columns = raw_display.iloc[0]
    raw_display = raw_display[1:]
    raw_display = raw_display.reset_index(drop=True)
    gamelog_table = raw_display[raw_display['PLAYER_NAME'] != ""]
    gamelog_table = gamelog_table[['PLAYER_NAME', 'POS', 'TEAM_NAME', 'OPP_NAME', 'SEASON_ID', 'GAME_DATE', 'MATCHUP', 'MIN', 'touches', 'PTS', 'FGM', 'FGA', 'FG_PCT', 'FG3M', 'FG3A',
                                   'FG3_PCT', 'FTM', 'FTA', 'FT_PCT', 'reboundChancesOffensive', 'OREB', 'reboundChancesDefensive', 'DREB', 'reboundChancesTotal', 'REB',
                                   'passes', 'secondaryAssists', 'freeThrowAssists', 'assists', 'STL', 'BLK', 'TOV', 'PF', 'DD', 'TD', 'Fantasy', 'FD_Fantasy']]
    gamelog_table['assists'].replace("", 0, inplace=True)
    gamelog_table['reboundChancesTotal'].replace("", 0, inplace=True)
    gamelog_table['passes'].replace("", 0, inplace=True)
    gamelog_table['touches'].replace("", 0, inplace=True)
    gamelog_table['Fantasy'].replace("", 0, inplace=True)
    gamelog_table['FD_Fantasy'].replace("", 0, inplace=True)
    gamelog_table['REB'] = gamelog_table['REB'].astype(int)
    gamelog_table['assists'] = gamelog_table['assists'].astype(int)
    gamelog_table['reboundChancesTotal'] = gamelog_table['reboundChancesTotal'].astype(int)
    gamelog_table['passes'] = gamelog_table['passes'].astype(int)
    gamelog_table['touches'] = gamelog_table['touches'].astype(int)
    gamelog_table['Fantasy'] = gamelog_table['Fantasy'].astype(float)
    gamelog_table['FD_Fantasy'] = gamelog_table['FD_Fantasy'].astype(float)
    gamelog_table['rebound%'] = gamelog_table['REB'] / gamelog_table['reboundChancesTotal']
    gamelog_table['assists_per_pass'] = gamelog_table['assists'] / gamelog_table['passes']
    gamelog_table['Fantasy_per_touch'] = gamelog_table['Fantasy'] / gamelog_table['touches']
    gamelog_table['FD_Fantasy_per_touch'] = gamelog_table['FD_Fantasy'] / gamelog_table['touches']
    data_cols = gamelog_table.columns.drop(['PLAYER_NAME', 'POS', 'TEAM_NAME', 'OPP_NAME', 'SEASON_ID', 'GAME_DATE', 'MATCHUP'])
    gamelog_table[data_cols] = gamelog_table[data_cols].apply(pd.to_numeric, errors='coerce')
    gamelog_table['GAME_DATE'] = pd.to_datetime(gamelog_table['GAME_DATE']).dt.date
    
    gamelog_table = gamelog_table.set_axis(['Player', 'Pos', 'Team', 'Opp', 'Season', 'Date', 'Matchup', 'Min', 'Touches', 'Pts', 'FGM', 'FGA', 'FG%', 'FG3M', 'FG3A',
                                            'FG3%', 'FTM', 'FTA', 'FT%', 'OREB Chance', 'OREB', 'DREB Chance', 'DREB', 'REB Chance', 'REB',
                                            'Passes', 'Alt Assists', 'FT Assists', 'Assists', 'Stl', 'Blk', 'Tov', 'PF', 'DD', 'TD', 'Fantasy', 'FD_Fantasy',
                                            'Rebound%', 'Assists/Pass', 'Fantasy/Touch', 'FD Fantasy/Touch'], axis=1)
    
    return gamelog_table

@st.cache_data(show_spinner=False)
def seasonlong_build(data_sample):
    season_long_table = data_sample[['Player', 'Pos', 'Team']]
    season_long_table['Min'] = data_sample.groupby(['Player', 'Season'], sort=False)['Min'].transform('mean').astype(float)
    season_long_table['Touches'] = data_sample.groupby(['Player', 'Season'], sort=False)['Touches'].transform('mean').astype(float)
    season_long_table['Pts'] = data_sample.groupby(['Player', 'Season'], sort=False)['Pts'].transform('mean').astype(float)
    season_long_table['FGM'] = data_sample.groupby(['Player', 'Season'], sort=False)['FGM'].transform('mean').astype(float)
    season_long_table['FGA'] = data_sample.groupby(['Player', 'Season'], sort=False)['FGA'].transform('mean').astype(float)
    season_long_table['FG%'] = (data_sample.groupby(['Player', 'Season'], sort=False)['FGM'].transform('sum').astype(int) /
                                   data_sample.groupby(['Player', 'Season'], sort=False)['FGA'].transform('sum').astype(int))
    season_long_table['FG3M'] = data_sample.groupby(['Player', 'Season'], sort=False)['FG3M'].transform('mean').astype(float)
    season_long_table['FG3A'] = data_sample.groupby(['Player', 'Season'], sort=False)['FG3A'].transform('mean').astype(float)
    season_long_table['FG3%'] = (data_sample.groupby(['Player', 'Season'], sort=False)['FG3M'].transform('sum').astype(int) /
                                   data_sample.groupby(['Player', 'Season'], sort=False)['FG3A'].transform('sum').astype(int))
    season_long_table['FTM'] = data_sample.groupby(['Player', 'Season'], sort=False)['FTM'].transform('mean').astype(float)
    season_long_table['FTA'] = data_sample.groupby(['Player', 'Season'], sort=False)['FTA'].transform('mean').astype(float)
    season_long_table['FT%'] = (data_sample.groupby(['Player', 'Season'], sort=False)['FTM'].transform('sum').astype(int) /
                                   data_sample.groupby(['Player', 'Season'], sort=False)['FTA'].transform('sum').astype(int))
    season_long_table['OREB Chance'] = data_sample.groupby(['Player', 'Season'], sort=False)['OREB Chance'].transform('mean').astype(float)
    season_long_table['OREB'] = data_sample.groupby(['Player', 'Season'], sort=False)['OREB'].transform('mean').astype(float)
    season_long_table['DREB Chance'] = data_sample.groupby(['Player', 'Season'], sort=False)['DREB Chance'].transform('mean').astype(float)
    season_long_table['DREB'] = data_sample.groupby(['Player', 'Season'], sort=False)['DREB'].transform('mean').astype(float)
    season_long_table['REB Chance'] = data_sample.groupby(['Player', 'Season'], sort=False)['REB Chance'].transform('mean').astype(float)
    season_long_table['REB'] = data_sample.groupby(['Player', 'Season'], sort=False)['REB'].transform('mean').astype(float)
    season_long_table['Passes'] = data_sample.groupby(['Player', 'Season'], sort=False)['Passes'].transform('mean').astype(float)
    season_long_table['Alt Assists'] = data_sample.groupby(['Player', 'Season'], sort=False)['Alt Assists'].transform('mean').astype(float)
    season_long_table['FT Assists'] = data_sample.groupby(['Player', 'Season'], sort=False)['FT Assists'].transform('mean').astype(float)
    season_long_table['Assists'] = data_sample.groupby(['Player', 'Season'], sort=False)['Assists'].transform('mean').astype(float)
    season_long_table['Stl'] = data_sample.groupby(['Player', 'Season'], sort=False)['Stl'].transform('mean').astype(float)
    season_long_table['Blk'] = data_sample.groupby(['Player', 'Season'], sort=False)['Blk'].transform('mean').astype(float)
    season_long_table['Tov'] = data_sample.groupby(['Player', 'Season'], sort=False)['Tov'].transform('mean').astype(float)
    season_long_table['PF'] = data_sample.groupby(['Player', 'Season'], sort=False)['PF'].transform('mean').astype(float)
    season_long_table['DD'] = data_sample.groupby(['Player', 'Season'], sort=False)['DD'].transform('mean').astype(float)
    season_long_table['TD'] = data_sample.groupby(['Player', 'Season'], sort=False)['TD'].transform('mean').astype(float)
    season_long_table['Fantasy'] = data_sample.groupby(['Player', 'Season'], sort=False)['Fantasy'].transform('mean').astype(float)
    season_long_table['FD_Fantasy'] = data_sample.groupby(['Player', 'Season'], sort=False)['FD_Fantasy'].transform('mean').astype(float)
    season_long_table['Rebound%'] = (data_sample.groupby(['Player', 'Season'], sort=False)['REB'].transform('sum').astype(int) /
                                     data_sample.groupby(['Player', 'Season'], sort=False)['REB Chance'].transform('sum').astype(int))
    season_long_table['Assists/Pass'] = (data_sample.groupby(['Player', 'Season'], sort=False)['Assists'].transform('sum').astype(int) /
                                             data_sample.groupby(['Player', 'Season'], sort=False)['Passes'].transform('sum').astype(int))
    season_long_table['Fantasy/Touch'] = (data_sample.groupby(['Player', 'Season'], sort=False)['Fantasy'].transform('sum').astype(int) /
                                              data_sample.groupby(['Player', 'Season'], sort=False)['Touches'].transform('sum').astype(int))
    season_long_table['FD Fantasy/Touch'] = (data_sample.groupby(['Player', 'Season'], sort=False)['FD_Fantasy'].transform('sum').astype(int) /
                                                 data_sample.groupby(['Player', 'Season'], sort=False)['Touches'].transform('sum').astype(int))
    season_long_table = season_long_table.drop_duplicates(subset='Player')

    season_long_table = season_long_table.sort_values(by='Fantasy', ascending=False)
    
    season_long_table = season_long_table.set_axis(['Player', 'Pos', 'Team', 'Min', 'Touches', 'Pts', 'FGM', 'FGA', 'FG%', 'FG3M', 'FG3A',
                                                    'FG3%', 'FTM', 'FTA', 'FT%', 'OREB Chance', 'OREB', 'DREB Chance', 'DREB', 'REB Chance', 'REB',
                                                    'Passes', 'Alt Assists', 'FT Assists', 'Assists', 'Stl', 'Blk', 'Tov', 'PF', 'DD', 'TD', 'Fantasy', 'FD_Fantasy',
                                                    'Rebound%', 'Assists/Pass', 'Fantasy/Touch', 'FD Fantasy/Touch'], axis=1)

    return season_long_table

@st.cache_data(show_spinner=False)
def run_fantasy_corr(data_sample):
    cor_testing = data_sample
    cor_testing = cor_testing[cor_testing['Season'] == '22023']
    date_list = cor_testing['Date'].unique().tolist()
    player_list = cor_testing['Player'].unique().tolist()
    corr_frame = pd.DataFrame()
    corr_frame['DATE'] = date_list
    for player in player_list:
        player_testing = cor_testing[cor_testing['Player'] == player]
        fantasy_map = dict(zip(player_testing['Date'], player_testing['Fantasy']))
        corr_frame[player] = corr_frame['DATE'].map(fantasy_map)
    players_fantasy = corr_frame.drop('DATE', axis=1)
    corrM = players_fantasy.corr()
    
    return corrM

@st.cache_data(show_spinner=False)
def run_min_corr(data_sample):
    cor_testing = data_sample
    cor_testing = cor_testing[cor_testing['Season'] == '22023']
    date_list = cor_testing['Date'].unique().tolist()
    player_list = cor_testing['Player'].unique().tolist()
    corr_frame = pd.DataFrame()
    corr_frame['DATE'] = date_list
    for player in player_list:
        player_testing = cor_testing[cor_testing['Player'] == player]
        fantasy_map = dict(zip(player_testing['Date'], player_testing['Min']))
        corr_frame[player] = corr_frame['DATE'].map(fantasy_map)
    players_fantasy = corr_frame.drop('DATE', axis=1)
    corrM = players_fantasy.corr()
    
    return corrM

@st.cache_data(show_spinner=False)
def split_frame(input_df, rows):
    df = [input_df.loc[i : i + rows - 1, :] for i in range(0, len(input_df), rows)]
    return df

def convert_df_to_csv(df):
    return df.to_csv().encode('utf-8')

gamelog_table = init_baselines()
indv_teams = gamelog_table.drop_duplicates(subset='Team')
total_teams = indv_teams.Team.values.tolist()
indv_players = gamelog_table.drop_duplicates(subset='Player')
total_players = indv_players.Player.values.tolist()
total_dates = gamelog_table.Date.values.tolist()

tab1, tab2 = st.tabs(['Gamelogs', 'Correlation Matrix'])

with tab1:
    col1, col2 = st.columns([1, 9])
    with col1:
        if st.button("Reset Data", key='reset1'):
                  st.cache_data.clear()
                  gamelog_table = init_baselines()
                  indv_teams = gamelog_table.drop_duplicates(subset='Team')
                  total_teams = indv_teams.Team.values.tolist()
                  indv_players = gamelog_table.drop_duplicates(subset='Player')
                  total_players = indv_players.Player.values.tolist()
                  total_dates = gamelog_table.Date.values.tolist()
        
        split_var1 = st.radio("What table would you like to view?", ('Season Logs', 'Gamelogs'), key='split_var1')
        split_var2 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var2')
        
        if split_var2 == 'Specific Teams':
            team_var1 = st.multiselect('Which teams would you like to include in the tables?', options = total_teams, key='team_var1')
        elif split_var2 == 'All':
            team_var1 = total_teams
            
        split_var3 = st.radio("Would you like to view all dates or specific ones?", ('All', 'Specific Dates'), key='split_var3')
        
        if split_var3 == 'Specific Dates':
            low_date = st.date_input('Min Date:', value=None, format="YYYY-MM-DD", key='low_date')
            if low_date is not None:
                low_date = pd.to_datetime(low_date).date()
            high_date = st.date_input('Max Date:', value=None, format="YYYY-MM-DD", key='high_date')
            if high_date is not None:
                high_date = pd.to_datetime(high_date).date()
        elif split_var3 == 'All':
            low_date = gamelog_table['Date'].min()
            high_date = gamelog_table['Date'].max()
        
        split_var4 = st.radio("Would you like to view all players or specific ones?", ('All', 'Specific Players'), key='split_var4')
        
        if split_var4 == 'Specific Players':
            player_var1 = st.multiselect('Which players would you like to include in the tables?', options = total_players, key='player_var1')
        elif split_var4 == 'All':
            player_var1 = total_players
        
        min_var1 = st.slider("Is there a certain minutes range you want to view?", 0, 60, (0, 60), key='min_var1')
    
    with col2:
        if split_var1 == 'Season Logs':
            display = st.container()
            gamelog_table = gamelog_table[gamelog_table['Date'] >= low_date]
            gamelog_table = gamelog_table[gamelog_table['Date'] <= high_date]
            gamelog_table = gamelog_table[gamelog_table['Min'] >= min_var1[0]]
            gamelog_table = gamelog_table[gamelog_table['Min'] <= min_var1[1]]
            gamelog_table = gamelog_table[gamelog_table['Team'].isin(team_var1)]
            gamelog_table = gamelog_table[gamelog_table['Player'].isin(player_var1)]
            season_long_table = seasonlong_build(gamelog_table)
            season_long_table = season_long_table.set_index('Player')
            display.dataframe(season_long_table.style.format(precision=2), height=750, use_container_width = True)  
            
        elif split_var1 == 'Gamelogs':
            gamelog_table = gamelog_table[gamelog_table['Date'] >= low_date]
            gamelog_table = gamelog_table[gamelog_table['Date'] <= high_date]
            gamelog_table = gamelog_table[gamelog_table['Min'] >= min_var1[0]]
            gamelog_table = gamelog_table[gamelog_table['Min'] <= min_var1[1]]
            gamelog_table = gamelog_table[gamelog_table['Team'].isin(team_var1)]
            gamelog_table = gamelog_table[gamelog_table['Player'].isin(player_var1)]
            gamelog_table = gamelog_table.reset_index(drop=True)
            display = st.container()
        
            bottom_menu = st.columns((4, 1, 1))
            with bottom_menu[2]:
                batch_size = st.selectbox("Page Size", options=[25, 50, 100])
            with bottom_menu[1]:
                total_pages = (
                    int(len(gamelog_table) / batch_size) if int(len(gamelog_table) / batch_size) > 0 else 1
                )
                current_page = st.number_input(
                    "Page", min_value=1, max_value=total_pages, step=1
                )
            with bottom_menu[0]:
                st.markdown(f"Page **{current_page}** of **{total_pages}** ")
            
            
            pages = split_frame(gamelog_table, batch_size)
            # pages = pages.set_index('Player')
            display.dataframe(data=pages[current_page - 1].style.format(precision=2), height=500, use_container_width=True)
            
with tab2:
    col1, col2 = st.columns([1, 9])
    with col1:
        if st.button("Reset Data", key='reset2'):
                  st.cache_data.clear()
                  gamelog_table = init_baselines()
                  indv_teams = gamelog_table.drop_duplicates(subset='Team')
                  total_teams = indv_teams.Team.values.tolist()
                  indv_players = gamelog_table.drop_duplicates(subset='Player')
                  total_players = indv_players.Player.values.tolist()
                  total_dates = gamelog_table.Date.values.tolist()
        
        corr_var = st.radio("Are you correlating fantasy or minutes?", ('Fantasy', 'Minutes'), key='corr_var')
        
        split_var1_t2 = st.radio("Would you like to view specific teams or specific players?", ('Specific Teams', 'Specific Players'), key='split_var1_t2')
        
        if split_var1_t2 == 'Specific Teams':
            corr_var1_t2 = st.multiselect('Which teams would you like to include in the correlation?', options = total_teams, key='corr_var1_t2')
        elif split_var1_t2 == 'Specific Players':
            corr_var1_t2 = st.multiselect('Which players would you like to include in the correlation?', options = total_players, key='corr_var1_t2')
            
        split_var2_t2 = st.radio("Would you like to view all dates or specific ones?", ('All', 'Specific Dates'), key='split_var3_t2')
        
        if split_var2_t2 == 'Specific Dates':
            low_date_t2 = st.date_input('Min Date:', value=None, format="YYYY-MM-DD", key='low_date_t2')
            if low_date_t2 is not None:
                low_date_t2 = pd.to_datetime(low_date_t2).date()
            high_date_t2 = st.date_input('Max Date:', value=None, format="YYYY-MM-DD", key='high_date_t2')
            if high_date_t2 is not None:
                high_date_t2 = pd.to_datetime(high_date_t2).date()
        elif split_var2_t2 == 'All':
            low_date_t2 = gamelog_table['Date'].min()
            high_date_t2 = gamelog_table['Date'].max()
        
        min_var1_t2 = st.slider("Is there a certain minutes range you want to view?", 0, 60, (0, 60), key='min_var1_t2')
    
    with col2:
        if split_var1_t2 == 'Specific Teams':
            display = st.container()
            gamelog_table = gamelog_table.sort_values(by='Fantasy', ascending=False)
            gamelog_table = gamelog_table[gamelog_table['Date'] >= low_date_t2]
            gamelog_table = gamelog_table[gamelog_table['Date'] <= high_date_t2]
            gamelog_table = gamelog_table[gamelog_table['Min'] >= min_var1_t2[0]]
            gamelog_table = gamelog_table[gamelog_table['Min'] <= min_var1_t2[1]]
            gamelog_table = gamelog_table[gamelog_table['Team'].isin(corr_var1_t2)]
            if corr_var == 'Fantasy':
                corr_display = run_fantasy_corr(gamelog_table)
            elif corr_var == 'Minutes':
                corr_display = run_min_corr(gamelog_table)
            display.dataframe(corr_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height=1000, use_container_width = True)
            
        elif split_var1_t2 == 'Specific Players':
            display = st.container()
            gamelog_table = gamelog_table.sort_values(by='Fantasy', ascending=False)
            gamelog_table = gamelog_table[gamelog_table['Date'] >= low_date_t2]
            gamelog_table = gamelog_table[gamelog_table['Date'] <= high_date_t2]
            gamelog_table = gamelog_table[gamelog_table['Min'] >= min_var1_t2[0]]
            gamelog_table = gamelog_table[gamelog_table['Min'] <= min_var1_t2[1]]
            gamelog_table = gamelog_table[gamelog_table['Player'].isin(corr_var1_t2)]
            if corr_var == 'Fantasy':
                corr_display = run_fantasy_corr(gamelog_table)
            elif corr_var == 'Minutes':
                corr_display = run_min_corr(gamelog_table)
            display.dataframe(corr_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)