-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayerPerformanceFeatures.py
119 lines (73 loc) · 3.17 KB
/
playerPerformanceFeatures.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
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
import mysql.connector
import requests
from bs4 import BeautifulSoup
from ast import literal_eval
'''
def getPlayersFeatures (cursor, cnx, teamID, seasonID, dateID, playerID, position, opponentTeamID):
playerFeatures = [dateID, playerID, position, teamID, opponentTeamID, seasonID]
getPlayerPerformance = "SELECT * from playerPerformance where teamID = ", teamID, " and dateID = ", dateID
cursor.execute(getPlayerPerformance)\
xx = cursor.fetchall()
for x in [0, len(xx)]:
playerFeatures.extend(xx[x])
getPlayerTeamAverages = "SELECT * from teamAverages where teamID = ", teamID, " and season = ", seasonID
cursor.execute(getPlayerTeamAverages)
zz = cursor.fetchall()
for z in [0, len(zz)]:
playerFeatures.extend(zz[z])
getOpponentTeamVsPosition = "SELECT * from teamVs", position, " where teamID = ", opponentTeamID, " and season = ", seasonID
cursor.execute(getOpponentTeamVsPosition)
qq = cursor.fetchall()
for q in [0, len(qq)]:
playerFeatures.extend(qq[q])
getOpponentTeamAverages = "SELECT * from teamAverages where teamID = ", opponentTeamID, " and season = ", seasonID
cursor.execute(getOpponentTeamAverages)
tt = cursor.fetchall()
playerFeatures.extend(tt)
return playerFeatures
def getTeamFeatures(cursor, cnx, teamID, seasonID, dateID, opponentTeamID):
teamFeatures =[dateID, teamID, opponentTeamID, seasonID]
getTeamAverages = "SELECT * from teamAverages where teamID = ", teamID, " and seasonID = ", seasonID
cursor.execute(getTeamAverages)
xx = cursor.fetchall()
teamFeatures.extend(xx)
getOpponentTeamAverages = "SELECT * from teamAverages where teamID = ", opponentTeamID, " and season = ", seasonID, " and dateID = ", dateID, " and opponentTeamID = ", teamID
cursor.execute(getOpponentTeamAverages)
tt = cursor.fetchall()
teamFeatures.extend(tt)
return teamFeatures
'''
def insertDateID(cursor,cnx, tableName):
datesStatement = "select date from dates"
cursor.execute(datesStatement)
dates = cursor.fetchall()
for date in dates:
dd = "update ",tableName," SET dateID = (SELECT dateID from dates where date =", date, ")"
try:
cursor.execute(dd)
except:
def main():
cnx = mysql.connector.connect(user="wsa",
host="34.68.250.121",
database="NCAAWomens",
password="LeBron>MJ!")
cursor = cnx.cursor(buffered=True)
insertDateID(cursor,cnx,"scheduleStats")
teams = ("Michigan", "Michigan St.", "Illinois", "Indiana", "Iowa", "Maryland", "Minnesota", "Nebraska", "Northwestern", "Ohio St.", "Penn St.", "Purdue", "Rutgers", "Wisconsin")
'''
for team in teams:
teamID = team
for opponentTeam in teams.remove(team):
opponentTeamID = opponentTeam
seasonIDs = [1,2,3,4]
for season in seasonIDs:
selectGames = "SELECT dateID from teamPerformance where teamID = ", teamID
cursor.execute(selectGames)
games = cursor.fetchall()
for game in games:
getTeamFeatures(cursor,cnx,teamID,season,game, opponentTeamID)
#insertTeamFeatures = "INSERT into teamPerformanceFeatures "
'''
return
if __name__=="__main__":
main()