-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadvPlayerStats.py
47 lines (35 loc) · 1.6 KB
/
advPlayerStats.py
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
import scraper
from pprint import pprint
import heapq
playerDict2023 = scraper.createPlayerDict('2023_total')
scraper.addFPTS('2023_total')
scraper.roundStats('2023_total')
proTeamDict2023 = scraper.splitByProTeam(playerDict2023)
#TO DO:
#sort into real teams DONE
#get average fpts per top 6 on each team DONE
#get who was on which team last year
#get availability score per player by adding fpts of other players on the team
#get change in availability score
#calculate change in expected ftps with help of change in availability score
def addContestedScore(playerDict2023, proTeamDict2023):
#get average fpts of top 6 players on each team
for i in proTeamDict2023:
FPTSList = []
for j in proTeamDict2023[i]:
FPTSList.append(proTeamDict2023[i][j]['FPTS'])
top6 = heapq.nlargest(6, FPTSList)
avgFPTS = sum(top6)/len(top6)
proTeamDict2023[i].update({'FPTS':avgFPTS})
#print(avgFPTS)
#take away players own FPTS score from their team's top 6 and use that as their contested score
for i in playerDict2023:
team = playerDict2023[i]["PTEAM"]
contestedScore = proTeamDict2023[team]['FPTS']*6 - playerDict2023[i]['FPTS']
proTeamDict2023[team][i].update({'CONT':contestedScore})
#print(proTeamDict2023[team]['FPTS'], "MINUS", playerDict2023[i]['FPTS'], "EQUALS", contestedScore)
#print(i, " " ,contestedScore)
scraper.league = scraper.lLeague
playerDict2023 = scraper.createPlayerDict('2022_total')
proTeamDict2023 = scraper.splitByProTeam(playerDict2023)
addContestedScore(playerDict2023, proTeamDict2023)