restructure player coords
Browse files- nba_tracking_data_15_16.py +32 -43
nba_tracking_data_15_16.py
CHANGED
@@ -179,47 +179,36 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
|
|
179 |
ball_coords_x = moment[5][0][2]
|
180 |
ball_coords_y = moment[5][0][3]
|
181 |
ball_coords_z = moment[5][0][4]
|
182 |
-
for
|
183 |
-
team_id = player[0]
|
184 |
-
player_id = player[1]
|
185 |
-
x = player[2]
|
186 |
-
y = player[3]
|
187 |
-
z = player[4]
|
188 |
|
189 |
-
|
190 |
-
|
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 |
-
"player_id": player_id,
|
221 |
-
"x": x,
|
222 |
-
"y": y,
|
223 |
-
"z": z
|
224 |
-
}
|
225 |
-
}
|
|
|
179 |
ball_coords_x = moment[5][0][2]
|
180 |
ball_coords_y = moment[5][0][3]
|
181 |
ball_coords_z = moment[5][0][4]
|
182 |
+
player_coords = [{"team_id": i[0], "player_id": i[1], "x": i[2], "y": i[3], "z": i[4]} for i in moment[5][1:]]
|
|
|
|
|
|
|
|
|
|
|
183 |
|
184 |
+
moment_id += 1
|
185 |
+
# moment_id stop
|
186 |
+
if moment_id > 1000:
|
187 |
+
break
|
188 |
+
|
189 |
+
yield moment_id, {
|
190 |
+
"gameid": game_id,
|
191 |
+
"gamedate": game_date,
|
192 |
+
"eventid": event_id,
|
193 |
+
# "visitor": {
|
194 |
+
# "name": visitor_name,
|
195 |
+
# "teamid": visitor_team_id,
|
196 |
+
# "abbreviation": visitor_abbrev,
|
197 |
+
# "players": visitor_players
|
198 |
+
# },
|
199 |
+
# "home": {
|
200 |
+
# "name": home_name,
|
201 |
+
# "teamid": home_team_id,
|
202 |
+
# "abbreviation": home_abbrev,
|
203 |
+
# "players": home_players
|
204 |
+
# },
|
205 |
+
"quarter": quarter,
|
206 |
+
"game_clock": game_clock,
|
207 |
+
"shot_clock": shot_clock,
|
208 |
+
"ball_coordinates": {
|
209 |
+
"x": ball_coords_x,
|
210 |
+
"y": ball_coords_y,
|
211 |
+
"z": ball_coords_z
|
212 |
+
},
|
213 |
+
"player_coordinates": player_coords
|
214 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|