|  | 
| 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": "7d1791bd-9552-4116-90b2-daa678bbffb8", | 
| 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": "2901fbc9-49db-4285-8b94-c460f34d4c4f", | 
| 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": "655120e7-6b25-417c-a08a-c6925feaa425", | 
| 46 | 55 |      "showTitle": false, | 
|  | 
| 150 | 159 |    "execution_count": 0, | 
| 151 | 160 |    "metadata": { | 
| 152 | 161 |     "application/vnd.databricks.v1+cell": { | 
| 153 |  | -     "cellMetadata": {}, | 
|  | 162 | +     "cellMetadata": { | 
|  | 163 | +      "byteLimit": 2048000, | 
|  | 164 | +      "rowLimit": 10000 | 
|  | 165 | +     }, | 
| 154 | 166 |      "inputWidgets": {}, | 
| 155 | 167 |      "nuid": "a2368434-0191-416c-aa1d-12cd44cf48e6", | 
| 156 | 168 |      "showTitle": false, | 
| 157 | 169 |      "tableResultSettingsMap": {}, | 
| 158 | 170 |      "title": "" | 
| 159 | 171 |     } | 
| 160 | 172 |    }, | 
| 161 |  | -   "outputs": [], | 
|  | 173 | +   "outputs": [ | 
|  | 174 | +    { | 
|  | 175 | +     "output_type": "stream", | 
|  | 176 | +     "name": "stdout", | 
|  | 177 | +     "output_type": "stream", | 
|  | 178 | +     "text": [ | 
|  | 179 | +      "+---------+---------+\n|player_id|team_name|\n+---------+---------+\n|        1|  Arsenal|\n|        2|  Arsenal|\n|        3|  Arsenal|\n|        4|  Chelsea|\n|        5|  Chelsea|\n|        6|  Chelsea|\n+---------+---------+\n\n+---------+----------+-------+\n|pass_from|time_stamp|pass_to|\n+---------+----------+-------+\n|        1|     00:15|      2|\n|        2|     00:45|      3|\n|        3|     01:15|      1|\n|        4|     00:30|      1|\n|        2|     46:00|      3|\n|        3|     46:15|      4|\n|        1|     46:45|      2|\n|        5|     46:30|      6|\n+---------+----------+-------+\n\n" | 
|  | 180 | +     ] | 
|  | 181 | +    } | 
|  | 182 | +   ], | 
| 162 | 183 |    "source": [ | 
| 163 | 184 |     "teams_data_3384 = [\n", | 
| 164 | 185 |     "    (1, \"Arsenal\"),\n", | 
|  | 
| 188 | 209 |     "passes_df_3384 = spark.createDataFrame(passes_data_3384, passes_columns_3384)\n", | 
| 189 | 210 |     "passes_df_3384.show()" | 
| 190 | 211 |    ] | 
|  | 212 | +  }, | 
|  | 213 | +  { | 
|  | 214 | +   "cell_type": "code", | 
|  | 215 | +   "execution_count": 0, | 
|  | 216 | +   "metadata": { | 
|  | 217 | +    "application/vnd.databricks.v1+cell": { | 
|  | 218 | +     "cellMetadata": { | 
|  | 219 | +      "byteLimit": 2048000, | 
|  | 220 | +      "rowLimit": 10000 | 
|  | 221 | +     }, | 
|  | 222 | +     "inputWidgets": {}, | 
|  | 223 | +     "nuid": "8745ee23-6035-439d-a7bd-25b30575bed6", | 
|  | 224 | +     "showTitle": false, | 
|  | 225 | +     "tableResultSettingsMap": {}, | 
|  | 226 | +     "title": "" | 
|  | 227 | +    } | 
|  | 228 | +   }, | 
|  | 229 | +   "outputs": [], | 
|  | 230 | +   "source": [ | 
|  | 231 | +    "passes_df_3384 = passes_df_3384 \\\n", | 
|  | 232 | +    "                    .join(teams_df_3384\\\n", | 
|  | 233 | +    "                        .withColumnRenamed(\"player_id\", \"pass_from\"), on=\"pass_from\") \\\n", | 
|  | 234 | +    "                        .withColumnRenamed(\"team_name\", \"from_team\") \\\n", | 
|  | 235 | +    "                    .join(teams_df_3384\\\n", | 
|  | 236 | +    "                        .withColumnRenamed(\"player_id\", \"pass_to\"), on=\"pass_to\") \\\n", | 
|  | 237 | +    "                        .withColumnRenamed(\"team_name\", \"to_team\")" | 
|  | 238 | +   ] | 
|  | 239 | +  }, | 
|  | 240 | +  { | 
|  | 241 | +   "cell_type": "code", | 
|  | 242 | +   "execution_count": 0, | 
|  | 243 | +   "metadata": { | 
|  | 244 | +    "application/vnd.databricks.v1+cell": { | 
|  | 245 | +     "cellMetadata": { | 
|  | 246 | +      "byteLimit": 2048000, | 
|  | 247 | +      "rowLimit": 10000 | 
|  | 248 | +     }, | 
|  | 249 | +     "inputWidgets": {}, | 
|  | 250 | +     "nuid": "bbe39e77-a34e-4104-8879-e3662f09d075", | 
|  | 251 | +     "showTitle": false, | 
|  | 252 | +     "tableResultSettingsMap": {}, | 
|  | 253 | +     "title": "" | 
|  | 254 | +    } | 
|  | 255 | +   }, | 
|  | 256 | +   "outputs": [], | 
|  | 257 | +   "source": [ | 
|  | 258 | +    "passes_df_3384 = passes_df_3384\\\n", | 
|  | 259 | +    "                    .withColumn( \"minute\", split(col(\"time_stamp\"), \":\").getItem(0).cast(\"int\") * 60 + split(col(\"time_stamp\"), \":\").getItem(1).cast(\"int\"))\\\n", | 
|  | 260 | +    "                        .withColumn(\"half_number\", when(col(\"minute\") <= 45*60, 1).otherwise(2))\\\n", | 
|  | 261 | +    "                            .withColumn( \"dominance_point\", when(col(\"from_team\") == col(\"to_team\"), 1).otherwise(-1))" | 
|  | 262 | +   ] | 
|  | 263 | +  }, | 
|  | 264 | +  { | 
|  | 265 | +   "cell_type": "code", | 
|  | 266 | +   "execution_count": 0, | 
|  | 267 | +   "metadata": { | 
|  | 268 | +    "application/vnd.databricks.v1+cell": { | 
|  | 269 | +     "cellMetadata": { | 
|  | 270 | +      "byteLimit": 2048000, | 
|  | 271 | +      "rowLimit": 10000 | 
|  | 272 | +     }, | 
|  | 273 | +     "inputWidgets": {}, | 
|  | 274 | +     "nuid": "f93abb86-31a4-413d-8839-a93d6d554841", | 
|  | 275 | +     "showTitle": false, | 
|  | 276 | +     "tableResultSettingsMap": {}, | 
|  | 277 | +     "title": "" | 
|  | 278 | +    } | 
|  | 279 | +   }, | 
|  | 280 | +   "outputs": [ | 
|  | 281 | +    { | 
|  | 282 | +     "output_type": "display_data", | 
|  | 283 | +     "data": { | 
|  | 284 | +      "text/html": [ | 
|  | 285 | +       "<style scoped>\n", | 
|  | 286 | +       "  .table-result-container {\n", | 
|  | 287 | +       "    max-height: 300px;\n", | 
|  | 288 | +       "    overflow: auto;\n", | 
|  | 289 | +       "  }\n", | 
|  | 290 | +       "  table, th, td {\n", | 
|  | 291 | +       "    border: 1px solid black;\n", | 
|  | 292 | +       "    border-collapse: collapse;\n", | 
|  | 293 | +       "  }\n", | 
|  | 294 | +       "  th, td {\n", | 
|  | 295 | +       "    padding: 5px;\n", | 
|  | 296 | +       "  }\n", | 
|  | 297 | +       "  th {\n", | 
|  | 298 | +       "    text-align: left;\n", | 
|  | 299 | +       "  }\n", | 
|  | 300 | +       "</style><div class='table-result-container'><table class='table-result'><thead style='background-color: white'><tr><th>team_name</th><th>half_number</th><th>dominance</th></tr></thead><tbody><tr><td>Arsenal</td><td>1</td><td>3</td></tr><tr><td>Arsenal</td><td>2</td><td>1</td></tr><tr><td>Chelsea</td><td>1</td><td>-1</td></tr><tr><td>Chelsea</td><td>2</td><td>1</td></tr></tbody></table></div>" | 
|  | 301 | +      ] | 
|  | 302 | +     }, | 
|  | 303 | +     "metadata": { | 
|  | 304 | +      "application/vnd.databricks.v1+output": { | 
|  | 305 | +       "addedWidgets": {}, | 
|  | 306 | +       "aggData": [], | 
|  | 307 | +       "aggError": "", | 
|  | 308 | +       "aggOverflow": false, | 
|  | 309 | +       "aggSchema": [], | 
|  | 310 | +       "aggSeriesLimitReached": false, | 
|  | 311 | +       "aggType": "", | 
|  | 312 | +       "arguments": {}, | 
|  | 313 | +       "columnCustomDisplayInfos": {}, | 
|  | 314 | +       "data": [ | 
|  | 315 | +        [ | 
|  | 316 | +         "Arsenal", | 
|  | 317 | +         1, | 
|  | 318 | +         3 | 
|  | 319 | +        ], | 
|  | 320 | +        [ | 
|  | 321 | +         "Arsenal", | 
|  | 322 | +         2, | 
|  | 323 | +         1 | 
|  | 324 | +        ], | 
|  | 325 | +        [ | 
|  | 326 | +         "Chelsea", | 
|  | 327 | +         1, | 
|  | 328 | +         -1 | 
|  | 329 | +        ], | 
|  | 330 | +        [ | 
|  | 331 | +         "Chelsea", | 
|  | 332 | +         2, | 
|  | 333 | +         1 | 
|  | 334 | +        ] | 
|  | 335 | +       ], | 
|  | 336 | +       "datasetInfos": [], | 
|  | 337 | +       "dbfsResultPath": null, | 
|  | 338 | +       "isJsonSchema": true, | 
|  | 339 | +       "metadata": {}, | 
|  | 340 | +       "overflow": false, | 
|  | 341 | +       "plotOptions": { | 
|  | 342 | +        "customPlotOptions": {}, | 
|  | 343 | +        "displayType": "table", | 
|  | 344 | +        "pivotAggregation": null, | 
|  | 345 | +        "pivotColumns": null, | 
|  | 346 | +        "xColumns": null, | 
|  | 347 | +        "yColumns": null | 
|  | 348 | +       }, | 
|  | 349 | +       "removedWidgets": [], | 
|  | 350 | +       "schema": [ | 
|  | 351 | +        { | 
|  | 352 | +         "metadata": "{}", | 
|  | 353 | +         "name": "team_name", | 
|  | 354 | +         "type": "\"string\"" | 
|  | 355 | +        }, | 
|  | 356 | +        { | 
|  | 357 | +         "metadata": "{}", | 
|  | 358 | +         "name": "half_number", | 
|  | 359 | +         "type": "\"integer\"" | 
|  | 360 | +        }, | 
|  | 361 | +        { | 
|  | 362 | +         "metadata": "{}", | 
|  | 363 | +         "name": "dominance", | 
|  | 364 | +         "type": "\"long\"" | 
|  | 365 | +        } | 
|  | 366 | +       ], | 
|  | 367 | +       "type": "table" | 
|  | 368 | +      } | 
|  | 369 | +     }, | 
|  | 370 | +     "output_type": "display_data" | 
|  | 371 | +    } | 
|  | 372 | +   ], | 
|  | 373 | +   "source": [ | 
|  | 374 | +    "passes_df_3384\\\n", | 
|  | 375 | +    "    .groupBy(\"from_team\", \"half_number\") \\\n", | 
|  | 376 | +    "        .sum(\"dominance_point\") \\\n", | 
|  | 377 | +    "            .withColumnRenamed(\"from_team\", \"team_name\") \\\n", | 
|  | 378 | +    "                .withColumnRenamed(\"sum(dominance_point)\", \"dominance\") \\\n", | 
|  | 379 | +    "                    .orderBy(\"team_name\", \"half_number\").display()" | 
|  | 380 | +   ] | 
| 191 | 381 |   } | 
| 192 | 382 |  ], | 
| 193 | 383 |  "metadata": { | 
| 194 | 384 |   "application/vnd.databricks.v1+notebook": { | 
| 195 |  | -   "computePreferences": null, | 
|  | 385 | +   "computePreferences": { | 
|  | 386 | +    "hardware": { | 
|  | 387 | +     "accelerator": null, | 
|  | 388 | +     "gpuPoolId": null, | 
|  | 389 | +     "memory": null | 
|  | 390 | +    } | 
|  | 391 | +   }, | 
| 196 | 392 |    "dashboards": [], | 
| 197 | 393 |    "environmentMetadata": { | 
| 198 | 394 |     "base_environment": "", | 
| 199 |  | -    "environment_version": "1" | 
|  | 395 | +    "environment_version": "2" | 
| 200 | 396 |    }, | 
| 201 | 397 |    "inputWidgetPreferences": null, | 
| 202 | 398 |    "language": "python", | 
|  | 
0 commit comments