dcayton commited on
Commit
6927e11
1 Parent(s): 718548c

structure change

Browse files
Files changed (1) hide show
  1. nba_tracking_data_15_16.py +46 -70
nba_tracking_data_15_16.py CHANGED
@@ -61,71 +61,51 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
61
  "gameid": datasets.Value("string"),
62
  "gamedate": datasets.Value("string"),
63
  # question: how to indicate list of dictionaries?
64
- "events": datasets.Sequence(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  {
66
- "eventid": datasets.Value("string"),
67
- # "visitor": {
68
- # "name": datasets.Value("string"),
69
- # "teamid": datasets.Value("int64"),
70
- # "abbreviation": datasets.Value("string"),
71
- # "players": datasets.Sequence({
72
- # "lastname": datasets.Value("string"),
73
- # "firstname": datasets.Value("string"),
 
 
 
74
  # "playerid": datasets.Value("int64"),
75
- # "jersey": datasets.Value("string"),
76
- # "position": datasets.Value("string")
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
- # },
91
- "moments": datasets.Sequence(
92
- # question, how to indicate lists of lists of different types
93
- {
94
- "quarter": datasets.Value("int64"),
95
- # "game_clock": datasets.Value("float32"),
96
- # "shot_clock": datasets.Value("float32"),
97
- # "ball_coordinates": datasets.Sequence(
98
- # datasets.Value("float32"),
99
- # datasets.Value("float32"),
100
- # datasets.Value("float32")
101
- # ),
102
- # "player_coordinates": datasets.Sequence(
103
- # {
104
- # "teamid": datasets.Value("int64"),
105
- # "playerid": datasets.Value("int64"),
106
- # "x": datasets.Value("float32"),
107
- # "y": datasets.Value("float32"),
108
- # "z": datasets.Value("float32")
109
- # }
110
- # )
111
- }
112
- # datasets.Sequence(
113
- # datasets.Value("int64"),
114
- # datasets.Value("float32"),
115
- # datasets.Value("float32"),
116
- # datasets.Value("float32"),
117
- # datasets.Value("null"),
118
- # datasets.Sequence(
119
- # datasets.Sequence(
120
- # datasets.Value("int64"),
121
- # datasets.Value("int64"),
122
- # datasets.Value("float32"),
123
- # datasets.Value("float32"),
124
- # datasets.Value("float32")
125
- # )
126
- # )
127
- # )
128
- )
129
  }
130
  )
131
  }
@@ -181,10 +161,8 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
181
  game_id = game["gameid"]
182
  game_date = game["gamedate"]
183
  for event in game["events"]:
184
- print(type(event))
185
  event_id = event["eventId"]
186
  for moment in event["moments"]:
187
- print(type(moment))
188
  quarter = moment[0]
189
  game_clock = moment[2]
190
  shot_clock = moment[3]
@@ -200,10 +178,9 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
200
  yield moment_id, {
201
  "gameid": game_id,
202
  "gamedate": game_date,
203
- "events": {
204
- "eventid": event_id,
205
- "moments": {
206
- "quarter": quarter,
207
  # "game_clock": game_clock,
208
  # "shot_clock": shot_clock,
209
  # "ball_coordinates": ball_coords,
@@ -216,7 +193,6 @@ class NbaTracking(datasets.GeneratorBasedBuilder):
216
  # }
217
  }
218
  }
219
- }
220
 
221
 
222
  # for key, row in enumerate(fp):
 
61
  "gameid": datasets.Value("string"),
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": datasets.Sequence({
70
+ # "lastname": datasets.Value("string"),
71
+ # "firstname": datasets.Value("string"),
72
+ # "playerid": datasets.Value("int64"),
73
+ # "jersey": datasets.Value("string"),
74
+ # "position": datasets.Value("string")
75
+ # })
76
+ # },
77
+ # "home": {
78
+ # "name": datasets.Value("string"),
79
+ # "teamid": datasets.Value("int64"),
80
+ # "abbreviation": datasets.Value("string"),
81
+ # "players": datasets.Sequence({
82
+ # "lastname": datasets.Value("string"),
83
+ # "firstname": datasets.Value("string"),
84
+ # "playerid": datasets.Value("int64"),
85
+ # "jersey": datasets.Value("string"),
86
+ # "position": datasets.Value("string")
87
+ # })
88
+ },
89
+ "moments": datasets.Sequence(
90
+ # question, how to indicate lists of lists of different types
91
  {
92
+ "quarter": datasets.Value("int64"),
93
+ # "game_clock": datasets.Value("float32"),
94
+ # "shot_clock": datasets.Value("float32"),
95
+ # "ball_coordinates": datasets.Sequence(
96
+ # datasets.Value("float32"),
97
+ # datasets.Value("float32"),
98
+ # datasets.Value("float32")
99
+ # ),
100
+ # "player_coordinates": datasets.Sequence(
101
+ # {
102
+ # "teamid": datasets.Value("int64"),
103
  # "playerid": datasets.Value("int64"),
104
+ # "x": datasets.Value("float32"),
105
+ # "y": datasets.Value("float32"),
106
+ # "z": datasets.Value("float32")
107
+ # }
108
+ # )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  }
110
  )
111
  }
 
161
  game_id = game["gameid"]
162
  game_date = game["gamedate"]
163
  for event in game["events"]:
 
164
  event_id = event["eventId"]
165
  for moment in event["moments"]:
 
166
  quarter = moment[0]
167
  game_clock = moment[2]
168
  shot_clock = moment[3]
 
178
  yield moment_id, {
179
  "gameid": game_id,
180
  "gamedate": game_date,
181
+ "eventid": event_id,
182
+ "moments": {
183
+ "quarter": quarter,
 
184
  # "game_clock": game_clock,
185
  # "shot_clock": shot_clock,
186
  # "ball_coordinates": ball_coords,
 
193
  # }
194
  }
195
  }
 
196
 
197
 
198
  # for key, row in enumerate(fp):