4
4
"cell_type" : " markdown" ,
5
5
"metadata" : {
6
6
"application/vnd.databricks.v1+cell" : {
7
- "cellMetadata" : {},
7
+ "cellMetadata" : {
8
+ "byteLimit" : 2048000 ,
9
+ "rowLimit" : 10000
10
+ },
8
11
"inputWidgets" : {},
9
12
"nuid" : " 82383caa-9b15-409a-9acb-968b851c477b" ,
10
13
"showTitle" : false ,
21
24
"execution_count" : 0 ,
22
25
"metadata" : {
23
26
"application/vnd.databricks.v1+cell" : {
24
- "cellMetadata" : {},
27
+ "cellMetadata" : {
28
+ "byteLimit" : 2048000 ,
29
+ "rowLimit" : 10000
30
+ },
25
31
"inputWidgets" : {},
26
32
"nuid" : " 83322872-9913-4063-98cf-4aaea5fd3337" ,
27
33
"showTitle" : false ,
40
46
"cell_type" : " markdown" ,
41
47
"metadata" : {
42
48
"application/vnd.databricks.v1+cell" : {
43
- "cellMetadata" : {},
49
+ "cellMetadata" : {
50
+ "byteLimit" : 2048000 ,
51
+ "rowLimit" : 10000
52
+ },
44
53
"inputWidgets" : {},
45
54
"nuid" : " e475f002-2b95-4d27-958c-aeab86c066ed" ,
46
55
"showTitle" : false ,
124
133
"execution_count" : 0 ,
125
134
"metadata" : {
126
135
"application/vnd.databricks.v1+cell" : {
127
- "cellMetadata" : {},
136
+ "cellMetadata" : {
137
+ "byteLimit" : 2048000 ,
138
+ "rowLimit" : 10000
139
+ },
128
140
"inputWidgets" : {},
129
141
"nuid" : " a073d765-b3a4-4bda-a02f-ac5e3671a222" ,
130
142
"showTitle" : false ,
158
170
" matches_df_1212 = spark.createDataFrame(matches_data_1212, matches_columns_1212)\n " ,
159
171
" matches_df_1212.show()"
160
172
]
173
+ },
174
+ {
175
+ "cell_type" : " code" ,
176
+ "execution_count" : 0 ,
177
+ "metadata" : {
178
+ "application/vnd.databricks.v1+cell" : {
179
+ "cellMetadata" : {
180
+ "byteLimit" : 2048000 ,
181
+ "rowLimit" : 10000
182
+ },
183
+ "inputWidgets" : {},
184
+ "nuid" : " 0d53ec9e-0db8-4070-90c2-0cffb4ef13f5" ,
185
+ "showTitle" : false ,
186
+ "tableResultSettingsMap" : {},
187
+ "title" : " "
188
+ }
189
+ },
190
+ "outputs" : [],
191
+ "source" : [
192
+ " host_df_1212 = matches_df_1212.select(\n " ,
193
+ " col(\" host_team\" ).alias(\" team_id\" ),\n " ,
194
+ " when(col(\" host_goals\" ) > col(\" guest_goals\" ), 3)\n " ,
195
+ " .when(col(\" host_goals\" ) == col(\" guest_goals\" ), 1)\n " ,
196
+ " .otherwise(0)\n " ,
197
+ " .alias(\" points\" )\n " ,
198
+ " )"
199
+ ]
200
+ },
201
+ {
202
+ "cell_type" : " code" ,
203
+ "execution_count" : 0 ,
204
+ "metadata" : {
205
+ "application/vnd.databricks.v1+cell" : {
206
+ "cellMetadata" : {
207
+ "byteLimit" : 2048000 ,
208
+ "rowLimit" : 10000
209
+ },
210
+ "inputWidgets" : {},
211
+ "nuid" : " 8a77b973-b826-4986-9634-7fc0ec8cfe48" ,
212
+ "showTitle" : false ,
213
+ "tableResultSettingsMap" : {},
214
+ "title" : " "
215
+ }
216
+ },
217
+ "outputs" : [],
218
+ "source" : [
219
+ " guest_df_1212 = matches_df_1212.select(\n " ,
220
+ " col(\" guest_team\" ).alias(\" team_id\" ),\n " ,
221
+ " when(col(\" guest_goals\" ) > col(\" host_goals\" ), 3)\n " ,
222
+ " .when(col(\" guest_goals\" ) == col(\" host_goals\" ), 1)\n " ,
223
+ " .otherwise(0)\n " ,
224
+ " .alias(\" points\" )\n " ,
225
+ " )"
226
+ ]
227
+ },
228
+ {
229
+ "cell_type" : " code" ,
230
+ "execution_count" : 0 ,
231
+ "metadata" : {
232
+ "application/vnd.databricks.v1+cell" : {
233
+ "cellMetadata" : {
234
+ "byteLimit" : 2048000 ,
235
+ "rowLimit" : 10000
236
+ },
237
+ "inputWidgets" : {},
238
+ "nuid" : " 3efb888d-7a40-4caa-9389-651afd14488b" ,
239
+ "showTitle" : false ,
240
+ "tableResultSettingsMap" : {},
241
+ "title" : " "
242
+ }
243
+ },
244
+ "outputs" : [],
245
+ "source" : [
246
+ " points_df_1212 = host_df_1212.union(guest_df_1212)"
247
+ ]
248
+ },
249
+ {
250
+ "cell_type" : " code" ,
251
+ "execution_count" : 0 ,
252
+ "metadata" : {
253
+ "application/vnd.databricks.v1+cell" : {
254
+ "cellMetadata" : {
255
+ "byteLimit" : 2048000 ,
256
+ "rowLimit" : 10000
257
+ },
258
+ "inputWidgets" : {},
259
+ "nuid" : " 5056a058-2a62-46e6-95e1-f388b158b69b" ,
260
+ "showTitle" : false ,
261
+ "tableResultSettingsMap" : {},
262
+ "title" : " "
263
+ }
264
+ },
265
+ "outputs" : [],
266
+ "source" : [
267
+ " team_points_df_1212 = points_df_1212.groupBy(\" team_id\" ).agg(sum(\" points\" ).alias(\" num_points\" ))"
268
+ ]
269
+ },
270
+ {
271
+ "cell_type" : " code" ,
272
+ "execution_count" : 0 ,
273
+ "metadata" : {
274
+ "application/vnd.databricks.v1+cell" : {
275
+ "cellMetadata" : {
276
+ "byteLimit" : 2048000 ,
277
+ "rowLimit" : 10000
278
+ },
279
+ "inputWidgets" : {},
280
+ "nuid" : " 326f1ae2-4987-49b0-9e98-976e79b121f1" ,
281
+ "showTitle" : false ,
282
+ "tableResultSettingsMap" : {},
283
+ "title" : " "
284
+ }
285
+ },
286
+ "outputs" : [],
287
+ "source" : [
288
+ " team_points_df_1212\\\n " ,
289
+ " .join(teams_df_1212, on=\" team_id\" , how=\" right\" ).fillna(0)\\\n " ,
290
+ " .select(\" team_id\" , \" team_name\" , \" num_points\" ) \\\n " ,
291
+ " .orderBy(col(\" num_points\" ).desc(), col(\" team_id\" )).show()"
292
+ ]
161
293
}
162
294
],
163
295
"metadata" : {
164
296
"application/vnd.databricks.v1+notebook" : {
165
- "computePreferences" : null ,
297
+ "computePreferences" : {
298
+ "hardware" : {
299
+ "accelerator" : null ,
300
+ "gpuPoolId" : null ,
301
+ "memory" : null
302
+ }
303
+ },
166
304
"dashboards" : [],
167
305
"environmentMetadata" : {
168
306
"base_environment" : " " ,
169
- "environment_version" : " 1 "
307
+ "environment_version" : " 2 "
170
308
},
171
309
"inputWidgetPreferences" : null ,
172
310
"language" : " python" ,
173
311
"notebookMetadata" : {
174
312
"pythonIndentUnit" : 4
175
313
},
176
- "notebookName" : " 1212. Team Scores in Football Tournament (Medium)" ,
314
+ "notebookName" : " 1212. Team Scores in Football Tournament (Medium)-(Solved) " ,
177
315
"widgets" : {}
316
+ },
317
+ "language_info" : {
318
+ "name" : " python"
178
319
}
179
320
},
180
321
"nbformat" : 4 ,
181
322
"nbformat_minor" : 0
182
- }
323
+ }
0 commit comments