moments structure changed
Browse files- nba_tracking_data_15_16.py +42 -43
nba_tracking_data_15_16.py
CHANGED
@@ -89,7 +89,7 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
|
|
89 |
}
|
90 |
]
|
91 |
},
|
92 |
-
"
|
93 |
{
|
94 |
"quarter": datasets.Value("int64"),
|
95 |
"game_clock": datasets.Value("float32"),
|
@@ -174,46 +174,45 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
|
|
174 |
home_team_id = event['home']['teamid']
|
175 |
home_abbrev = event['home']['abbreviation']
|
176 |
home_players = event['home']['players']
|
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 |
-
"game_clock": game_clock,
|
211 |
-
"shot_clock": shot_clock,
|
212 |
-
"ball_coordinates": {
|
213 |
-
"x": ball_coords_x,
|
214 |
-
"y": ball_coords_y,
|
215 |
-
"z": ball_coords_z
|
216 |
-
},
|
217 |
-
"player_coordinates": player_coords
|
218 |
-
}
|
219 |
-
}
|
|
|
89 |
}
|
90 |
]
|
91 |
},
|
92 |
+
"moments": [
|
93 |
{
|
94 |
"quarter": datasets.Value("int64"),
|
95 |
"game_clock": datasets.Value("float32"),
|
|
|
174 |
home_team_id = event['home']['teamid']
|
175 |
home_abbrev = event['home']['abbreviation']
|
176 |
home_players = event['home']['players']
|
177 |
+
|
178 |
+
moments = [
|
179 |
+
{
|
180 |
+
"quarter": moment[0],
|
181 |
+
"game_clock": moment[2],
|
182 |
+
"shot_clock": moment[3],
|
183 |
+
"ball_coordinates": moment[5][0][2:],
|
184 |
+
"player_coordinates": [
|
185 |
+
{
|
186 |
+
"teamid": i[0],
|
187 |
+
"playerid": i[1],
|
188 |
+
"x": i[2],
|
189 |
+
"y": i[3],
|
190 |
+
"z": i[4]
|
191 |
+
} for i in moment[5][1:]
|
192 |
+
]
|
193 |
+
} for moment in event["moments"]
|
194 |
+
]
|
195 |
+
|
196 |
+
moment_id += 1
|
197 |
+
# moment_id stop
|
198 |
+
if moment_id > 1000:
|
199 |
+
break
|
200 |
|
201 |
+
yield moment_id, {
|
202 |
+
"gameid": game_id,
|
203 |
+
"gamedate": game_date,
|
204 |
+
"eventid": event_id,
|
205 |
+
"visitor": {
|
206 |
+
"name": visitor_name,
|
207 |
+
"teamid": visitor_team_id,
|
208 |
+
"abbreviation": visitor_abbrev,
|
209 |
+
"players": visitor_players
|
210 |
+
},
|
211 |
+
"home": {
|
212 |
+
"name": home_name,
|
213 |
+
"teamid": home_team_id,
|
214 |
+
"abbreviation": home_abbrev,
|
215 |
+
"players": home_players
|
216 |
+
},
|
217 |
+
"moments": moments
|
218 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|