44 "cell_type" : " markdown" ,
55 "metadata" : {
66 "application/vnd.databricks.v1+cell" : {
7- "cellMetadata" : {},
7+ "cellMetadata" : {
8+ "byteLimit" : 2048000 ,
9+ "rowLimit" : 10000
10+ },
811 "inputWidgets" : {},
912 "nuid" : " 82383caa-9b15-409a-9acb-968b851c477b" ,
1013 "showTitle" : false ,
2124 "execution_count" : 0 ,
2225 "metadata" : {
2326 "application/vnd.databricks.v1+cell" : {
24- "cellMetadata" : {},
27+ "cellMetadata" : {
28+ "byteLimit" : 2048000 ,
29+ "rowLimit" : 10000
30+ },
2531 "inputWidgets" : {},
2632 "nuid" : " 83322872-9913-4063-98cf-4aaea5fd3337" ,
2733 "showTitle" : false ,
4046 "cell_type" : " markdown" ,
4147 "metadata" : {
4248 "application/vnd.databricks.v1+cell" : {
43- "cellMetadata" : {},
49+ "cellMetadata" : {
50+ "byteLimit" : 2048000 ,
51+ "rowLimit" : 10000
52+ },
4453 "inputWidgets" : {},
4554 "nuid" : " e475f002-2b95-4d27-958c-aeab86c066ed" ,
4655 "showTitle" : false ,
124133 "execution_count" : 0 ,
125134 "metadata" : {
126135 "application/vnd.databricks.v1+cell" : {
127- "cellMetadata" : {},
136+ "cellMetadata" : {
137+ "byteLimit" : 2048000 ,
138+ "rowLimit" : 10000
139+ },
128140 "inputWidgets" : {},
129141 "nuid" : " a073d765-b3a4-4bda-a02f-ac5e3671a222" ,
130142 "showTitle" : false ,
158170 " matches_df_1212 = spark.createDataFrame(matches_data_1212, matches_columns_1212)\n " ,
159171 " matches_df_1212.show()"
160172 ]
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+ ]
161293 }
162294 ],
163295 "metadata" : {
164296 "application/vnd.databricks.v1+notebook" : {
165- "computePreferences" : null ,
297+ "computePreferences" : {
298+ "hardware" : {
299+ "accelerator" : null ,
300+ "gpuPoolId" : null ,
301+ "memory" : null
302+ }
303+ },
166304 "dashboards" : [],
167305 "environmentMetadata" : {
168306 "base_environment" : " " ,
169- "environment_version" : " 1 "
307+ "environment_version" : " 2 "
170308 },
171309 "inputWidgetPreferences" : null ,
172310 "language" : " python" ,
173311 "notebookMetadata" : {
174312 "pythonIndentUnit" : 4
175313 },
176- "notebookName" : " 1212. Team Scores in Football Tournament (Medium)" ,
314+ "notebookName" : " 1212. Team Scores in Football Tournament (Medium)-(Solved) " ,
177315 "widgets" : {}
316+ },
317+ "language_info" : {
318+ "name" : " python"
178319 }
179320 },
180321 "nbformat" : 4 ,
181322 "nbformat_minor" : 0
182- }
323+ }
0 commit comments