Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -189,34 +189,40 @@ schedule_stack.head()
|
|
189 |
|
190 |
FontProperties(fname='/System/Library/Fonts/Apple Color Emoji.ttc')
|
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 |
def get_all_teams():
|
@@ -256,12 +262,12 @@ def get_all_players_teams():
|
|
256 |
|
257 |
return players_teams
|
258 |
|
259 |
-
|
260 |
|
261 |
|
262 |
-
df_2023 = pd.read_csv('df_2023_small.csv',index_col=[0])
|
263 |
df_2023.percent_owned = df_2023.percent_owned.astype(float)
|
264 |
-
df_2023.columns = ['player_id','rank_value','full','first','last','average_pick', 'average_cost','display_position','projected_auction_value','editorial_team_abbr','percent_owned','status']
|
265 |
df_2023.status = df_2023.status.astype(str)
|
266 |
df_2023 = df_2023[df_2023.status.isin(['True','DTD'])]
|
267 |
|
|
|
189 |
|
190 |
FontProperties(fname='/System/Library/Fonts/Apple Color Emoji.ttc')
|
191 |
|
192 |
+
try:
|
193 |
+
data_r = requests.get("https://pub-api-ro.fantasysports.yahoo.com/fantasy/v2/league/453.l.public;out=settings/players;position=ALL;start=0;count=3000;sort=rank_season;search=;out=percent_owned;out=auction_values,ranks;ranks=season;ranks_by_position=season;out=expert_ranks;expert_ranks.rank_type=projected_season_remaining/draft_analysis;cut_types=diamond;slices=last7days?format=json_f").json()
|
194 |
+
key_check = data_r['fantasy_content']['league']['players']
|
195 |
+
|
196 |
+
except KeyError:
|
197 |
+
data_r = requests.get("https://pub-api-ro.fantasysports.yahoo.com/fantasy/v2/league/453.l.public;out=settings/players;position=ALL;start=0;count=400;sort=rank_season;search=;out=percent_owned;out=auction_values,ranks;ranks=season;ranks_by_position=season;out=expert_ranks;expert_ranks.rank_type=projected_season_remaining/draft_analysis;cut_types=diamond;slices=last7days?format=json_f").json()
|
198 |
+
print('key_checked')
|
199 |
+
|
200 |
+
total_list = []
|
201 |
+
|
202 |
+
for x in data_r['fantasy_content']['league']['players']:
|
203 |
+
single_list = []
|
204 |
+
|
205 |
+
single_list.append(int(x['player']['player_id']))
|
206 |
+
single_list.append(int(x['player']['player_ranks'][0]['player_rank']['rank_value']))
|
207 |
+
single_list.append(x['player']['name']['full'])
|
208 |
+
single_list.append(x['player']['name']['first'])
|
209 |
+
single_list.append(x['player']['name']['last'])
|
210 |
+
single_list.append(x['player']['draft_analysis']['average_pick'])
|
211 |
+
single_list.append(x['player']['average_auction_cost'])
|
212 |
+
single_list.append(x['player']['projected_auction_value'])
|
213 |
+
single_list.append(x['player']['display_position'])
|
214 |
+
single_list.append(x['player']['editorial_team_abbr'])
|
215 |
+
if 'value' in x['player']['percent_owned']:
|
216 |
+
single_list.append(x['player']['percent_owned']['value']/100)
|
217 |
+
else:
|
218 |
+
single_list.append(0)
|
219 |
+
|
220 |
+
if 'status' in x['player']:
|
221 |
+
single_list.append(x['player']['status'])
|
222 |
+
else:
|
223 |
+
single_list.append(True)
|
224 |
+
|
225 |
+
total_list.append(single_list)
|
226 |
|
227 |
|
228 |
def get_all_teams():
|
|
|
262 |
|
263 |
return players_teams
|
264 |
|
265 |
+
df_2023 = pd.DataFrame(data=total_list,columns=['player_id','rank_value','full','first','last','average_pick', 'average_cost','display_position','projected_auction_value','editorial_team_abbr','percent_owned','status'])
|
266 |
|
267 |
|
268 |
+
# df_2023 = pd.read_csv('df_2023_small.csv',index_col=[0])
|
269 |
df_2023.percent_owned = df_2023.percent_owned.astype(float)
|
270 |
+
#df_2023.columns = ['player_id','rank_value','full','first','last','average_pick', 'average_cost','display_position','projected_auction_value','editorial_team_abbr','percent_owned','status']
|
271 |
df_2023.status = df_2023.status.astype(str)
|
272 |
df_2023 = df_2023[df_2023.status.isin(['True','DTD'])]
|
273 |
|