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

add home functionality

Browse files
Files changed (1) hide show
  1. nba_tracking_data_15_16.py +27 -11
nba_tracking_data_15_16.py CHANGED
@@ -76,17 +76,20 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
76
  }
77
  ]
78
  },
79
- # "home": {
80
- # "name": datasets.Value("string"),
81
- # "teamid": datasets.Value("int64"),
82
- # "abbreviation": datasets.Value("string"),
83
- # "players": datasets.Sequence({
84
- # "lastname": datasets.Value("string"),
85
- # "firstname": datasets.Value("string"),
86
- # "playerid": datasets.Value("int64"),
87
- # "jersey": datasets.Value("string"),
88
- # "position": datasets.Value("string")
89
- # })
 
 
 
90
  "quarter": datasets.Value("int64"),
91
  "game_clock": datasets.Value("float32"),
92
  "shot_clock": datasets.Value("float32"),
@@ -158,10 +161,17 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
158
  game_date = game["gamedate"]
159
  for event in game["events"]:
160
  event_id = event["eventId"]
 
161
  visitor_name = event['visitor']['name']
162
  visitor_team_id = event['visitor']['teamid']
163
  visitor_abbrev = event['visitor']['abbreviation']
164
  visitor_players = event['visitor']['players']
 
 
 
 
 
 
165
  for moment in event["moments"]:
166
  quarter = moment[0]
167
  game_clock = moment[2]
@@ -191,6 +201,12 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
191
  "abbreviation": visitor_abbrev,
192
  "players": visitor_players
193
  },
 
 
 
 
 
 
194
  "quarter": quarter,
195
  "game_clock": game_clock,
196
  "shot_clock": shot_clock,
 
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"),
 
161
  game_date = game["gamedate"]
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]
177
  game_clock = moment[2]
 
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,