dcayton commited on
Commit
b07e71f
1 Parent(s): 69a246f

testing player coordinates

Browse files
Files changed (1) hide show
  1. nba_tracking_data_15_16.py +64 -57
nba_tracking_data_15_16.py CHANGED
@@ -62,34 +62,34 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
62
  "gamedate": datasets.Value("string"),
63
  # question: how to indicate list of dictionaries?
64
  "eventid": datasets.Value("string"),
65
- "visitor": {
66
- "name": datasets.Value("string"),
67
- "teamid": datasets.Value("int64"),
68
- "abbreviation": datasets.Value("string"),
69
- "players": [
70
- {
71
- "lastname": datasets.Value("string"),
72
- "firstname": datasets.Value("string"),
73
- "playerid": datasets.Value("int64"),
74
- "jersey": datasets.Value("string"),
75
- "position": datasets.Value("string")
76
- }
77
- ]
78
- },
79
- "home": {
80
- "name": datasets.Value("string"),
81
- "teamid": datasets.Value("int64"),
82
- "abbreviation": datasets.Value("string"),
83
- "players": [
84
- {
85
- "lastname": datasets.Value("string"),
86
- "firstname": datasets.Value("string"),
87
- "playerid": datasets.Value("int64"),
88
- "jersey": datasets.Value("string"),
89
- "position": datasets.Value("string")
90
- }
91
- ]
92
- },
93
  "quarter": datasets.Value("int64"),
94
  "game_clock": datasets.Value("float32"),
95
  "shot_clock": datasets.Value("float32"),
@@ -98,15 +98,15 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
98
  "y": datasets.Value("float32"),
99
  "z": datasets.Value("float32")
100
  },
101
- # "player_coordinates": datasets.Sequence(
102
- # {
103
- # "teamid": datasets.Value("int64"),
104
- # "playerid": datasets.Value("int64"),
105
- # "x": datasets.Value("float32"),
106
- # "y": datasets.Value("float32"),
107
- # "z": datasets.Value("float32")
108
- # }
109
- # )
110
  }
111
  )
112
 
@@ -162,15 +162,15 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
162
  for event in game["events"]:
163
  event_id = event["eventId"]
164
 
165
- visitor_name = event['visitor']['name']
166
- visitor_team_id = event['visitor']['teamid']
167
- visitor_abbrev = event['visitor']['abbreviation']
168
- visitor_players = event['visitor']['players']
169
 
170
- home_name = event['home']['name']
171
- home_team_id = event['home']['teamid']
172
- home_abbrev = event['home']['abbreviation']
173
- home_players = event['home']['players']
174
 
175
  for moment in event["moments"]:
176
  quarter = moment[0]
@@ -195,18 +195,18 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
195
  "gameid": game_id,
196
  "gamedate": game_date,
197
  "eventid": event_id,
198
- "visitor": {
199
- "name": visitor_name,
200
- "teamid": visitor_team_id,
201
- "abbreviation": visitor_abbrev,
202
- "players": visitor_players
203
- },
204
- "home": {
205
- "name": home_name,
206
- "teamid": home_team_id,
207
- "abbreviation": home_abbrev,
208
- "players": home_players
209
- },
210
  "quarter": quarter,
211
  "game_clock": game_clock,
212
  "shot_clock": shot_clock,
@@ -214,5 +214,12 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
214
  "x": ball_coords_x,
215
  "y": ball_coords_y,
216
  "z": ball_coords_z
 
 
 
 
 
 
 
217
  }
218
  }
 
62
  "gamedate": datasets.Value("string"),
63
  # question: how to indicate list of dictionaries?
64
  "eventid": datasets.Value("string"),
65
+ # "visitor": {
66
+ # "name": datasets.Value("string"),
67
+ # "teamid": datasets.Value("int64"),
68
+ # "abbreviation": datasets.Value("string"),
69
+ # "players": [
70
+ # {
71
+ # "lastname": datasets.Value("string"),
72
+ # "firstname": datasets.Value("string"),
73
+ # "playerid": datasets.Value("int64"),
74
+ # "jersey": datasets.Value("string"),
75
+ # "position": datasets.Value("string")
76
+ # }
77
+ # ]
78
+ # },
79
+ # "home": {
80
+ # "name": datasets.Value("string"),
81
+ # "teamid": datasets.Value("int64"),
82
+ # "abbreviation": datasets.Value("string"),
83
+ # "players": [
84
+ # {
85
+ # "lastname": datasets.Value("string"),
86
+ # "firstname": datasets.Value("string"),
87
+ # "playerid": datasets.Value("int64"),
88
+ # "jersey": datasets.Value("string"),
89
+ # "position": datasets.Value("string")
90
+ # }
91
+ # ]
92
+ # },
93
  "quarter": datasets.Value("int64"),
94
  "game_clock": datasets.Value("float32"),
95
  "shot_clock": datasets.Value("float32"),
 
98
  "y": datasets.Value("float32"),
99
  "z": datasets.Value("float32")
100
  },
101
+ "player_coordinates": [
102
+ {
103
+ "teamid": datasets.Value("int64"),
104
+ "playerid": datasets.Value("int64"),
105
+ "x": datasets.Value("float32"),
106
+ "y": datasets.Value("float32"),
107
+ "z": datasets.Value("float32")
108
+ }
109
+ ]
110
  }
111
  )
112
 
 
162
  for event in game["events"]:
163
  event_id = event["eventId"]
164
 
165
+ # visitor_name = event['visitor']['name']
166
+ # visitor_team_id = event['visitor']['teamid']
167
+ # visitor_abbrev = event['visitor']['abbreviation']
168
+ # visitor_players = event['visitor']['players']
169
 
170
+ # home_name = event['home']['name']
171
+ # home_team_id = event['home']['teamid']
172
+ # home_abbrev = event['home']['abbreviation']
173
+ # home_players = event['home']['players']
174
 
175
  for moment in event["moments"]:
176
  quarter = moment[0]
 
195
  "gameid": game_id,
196
  "gamedate": game_date,
197
  "eventid": event_id,
198
+ # "visitor": {
199
+ # "name": visitor_name,
200
+ # "teamid": visitor_team_id,
201
+ # "abbreviation": visitor_abbrev,
202
+ # "players": visitor_players
203
+ # },
204
+ # "home": {
205
+ # "name": home_name,
206
+ # "teamid": home_team_id,
207
+ # "abbreviation": home_abbrev,
208
+ # "players": home_players
209
+ # },
210
  "quarter": quarter,
211
  "game_clock": game_clock,
212
  "shot_clock": shot_clock,
 
214
  "x": ball_coords_x,
215
  "y": ball_coords_y,
216
  "z": ball_coords_z
217
+ },
218
+ "player_coordinates": {
219
+ "teamid": team_id,
220
+ "player_id", player_id,
221
+ "x": x,
222
+ "y": y,
223
+ "z": z
224
  }
225
  }