|
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": "24f8e8c0-d56b-4821-a900-bbe934dce4d7",
|
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": "243b190c-af0b-4bd1-9507-8e2be2fceca3",
|
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": "2d9dc49c-3f2c-4ff6-8e98-5e72a86b1bac",
|
46 | 55 | "showTitle": false,
|
|
126 | 135 | "execution_count": 0,
|
127 | 136 | "metadata": {
|
128 | 137 | "application/vnd.databricks.v1+cell": {
|
129 |
| - "cellMetadata": {}, |
| 138 | + "cellMetadata": { |
| 139 | + "byteLimit": 2048000, |
| 140 | + "rowLimit": 10000 |
| 141 | + }, |
130 | 142 | "inputWidgets": {},
|
131 | 143 | "nuid": "5d66d20c-58e2-4ee9-8356-d736216372c3",
|
132 | 144 | "showTitle": false,
|
133 | 145 | "tableResultSettingsMap": {},
|
134 | 146 | "title": ""
|
135 | 147 | }
|
136 | 148 | },
|
137 |
| - "outputs": [], |
| 149 | + "outputs": [ |
| 150 | + { |
| 151 | + "output_type": "stream", |
| 152 | + "name": "stdout", |
| 153 | + "output_type": "stream", |
| 154 | + "text": [ |
| 155 | + "+----------+------------+\n|student_id|student_name|\n+----------+------------+\n| 1| Daniel|\n| 2| Jade|\n| 3| Stella|\n| 4| Jonathan|\n| 5| Will|\n+----------+------------+\n\n+-------+----------+-----+\n|exam_id|student_id|score|\n+-------+----------+-----+\n| 10| 1| 70|\n| 10| 2| 80|\n| 10| 3| 90|\n| 20| 1| 80|\n| 30| 1| 70|\n| 30| 3| 80|\n| 30| 4| 90|\n| 40| 1| 60|\n| 40| 2| 70|\n| 40| 4| 80|\n+-------+----------+-----+\n\n" |
| 156 | + ] |
| 157 | + } |
| 158 | + ], |
138 | 159 | "source": [
|
139 | 160 | "students_data_1412 = [\n",
|
140 | 161 | " (1, \"Daniel\"),\n",
|
|
163 | 184 | "exams_df_1412 = spark.createDataFrame(exams_data_1412, exams_columns_1412)\n",
|
164 | 185 | "exams_df_1412.show()"
|
165 | 186 | ]
|
| 187 | + }, |
| 188 | + { |
| 189 | + "cell_type": "code", |
| 190 | + "execution_count": 0, |
| 191 | + "metadata": { |
| 192 | + "application/vnd.databricks.v1+cell": { |
| 193 | + "cellMetadata": { |
| 194 | + "byteLimit": 2048000, |
| 195 | + "rowLimit": 10000 |
| 196 | + }, |
| 197 | + "inputWidgets": {}, |
| 198 | + "nuid": "e0e45429-9fd7-4d46-b7c7-afcaebc7ccca", |
| 199 | + "showTitle": false, |
| 200 | + "tableResultSettingsMap": {}, |
| 201 | + "title": "" |
| 202 | + } |
| 203 | + }, |
| 204 | + "outputs": [], |
| 205 | + "source": [ |
| 206 | + "exam_scores_extremes_1412 = exams_df_1412\\\n", |
| 207 | + " .groupBy(\"exam_id\").agg(\n", |
| 208 | + " max(\"score\").alias(\"max_score\"),\n", |
| 209 | + " min(\"score\").alias(\"min_score\")\n", |
| 210 | + " )" |
| 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": "c63c1f95-9f20-4ebd-9d6b-ab7dd241ee72", |
| 224 | + "showTitle": false, |
| 225 | + "tableResultSettingsMap": {}, |
| 226 | + "title": "" |
| 227 | + } |
| 228 | + }, |
| 229 | + "outputs": [], |
| 230 | + "source": [ |
| 231 | + "extreme_students_1412 = exams_df_1412\\\n", |
| 232 | + " .join(exam_scores_extremes_1412, on=\"exam_id\") \\\n", |
| 233 | + " .filter((col(\"score\") == col(\"max_score\")) | (col(\"score\") == col(\"min_score\"))) \\\n", |
| 234 | + " .select(\"student_id\").distinct()" |
| 235 | + ] |
| 236 | + }, |
| 237 | + { |
| 238 | + "cell_type": "code", |
| 239 | + "execution_count": 0, |
| 240 | + "metadata": { |
| 241 | + "application/vnd.databricks.v1+cell": { |
| 242 | + "cellMetadata": { |
| 243 | + "byteLimit": 2048000, |
| 244 | + "rowLimit": 10000 |
| 245 | + }, |
| 246 | + "inputWidgets": {}, |
| 247 | + "nuid": "a0cdb742-949d-42bd-8a61-e63cac842647", |
| 248 | + "showTitle": false, |
| 249 | + "tableResultSettingsMap": {}, |
| 250 | + "title": "" |
| 251 | + } |
| 252 | + }, |
| 253 | + "outputs": [], |
| 254 | + "source": [ |
| 255 | + "students_with_exams_1412 = exams_df_1412.select(\"student_id\").distinct()" |
| 256 | + ] |
| 257 | + }, |
| 258 | + { |
| 259 | + "cell_type": "code", |
| 260 | + "execution_count": 0, |
| 261 | + "metadata": { |
| 262 | + "application/vnd.databricks.v1+cell": { |
| 263 | + "cellMetadata": { |
| 264 | + "byteLimit": 2048000, |
| 265 | + "rowLimit": 10000 |
| 266 | + }, |
| 267 | + "inputWidgets": {}, |
| 268 | + "nuid": "d9468b79-d159-4871-a756-b2d37830960f", |
| 269 | + "showTitle": false, |
| 270 | + "tableResultSettingsMap": {}, |
| 271 | + "title": "" |
| 272 | + } |
| 273 | + }, |
| 274 | + "outputs": [], |
| 275 | + "source": [ |
| 276 | + "quiet_students_1412 = students_with_exams_1412.join(extreme_students_1412, on=\"student_id\", how=\"left_anti\")" |
| 277 | + ] |
| 278 | + }, |
| 279 | + { |
| 280 | + "cell_type": "code", |
| 281 | + "execution_count": 0, |
| 282 | + "metadata": { |
| 283 | + "application/vnd.databricks.v1+cell": { |
| 284 | + "cellMetadata": { |
| 285 | + "byteLimit": 2048000, |
| 286 | + "rowLimit": 10000 |
| 287 | + }, |
| 288 | + "inputWidgets": {}, |
| 289 | + "nuid": "0a2549f6-43f1-44f8-af13-7271fc6a59e6", |
| 290 | + "showTitle": false, |
| 291 | + "tableResultSettingsMap": {}, |
| 292 | + "title": "" |
| 293 | + } |
| 294 | + }, |
| 295 | + "outputs": [ |
| 296 | + { |
| 297 | + "output_type": "stream", |
| 298 | + "name": "stdout", |
| 299 | + "output_type": "stream", |
| 300 | + "text": [ |
| 301 | + "+----------+------------+\n|student_id|student_name|\n+----------+------------+\n| 2| Jade|\n+----------+------------+\n\n" |
| 302 | + ] |
| 303 | + } |
| 304 | + ], |
| 305 | + "source": [ |
| 306 | + "quiet_students_1412\\\n", |
| 307 | + " .join(students_df_1412, on=\"student_id\") \\\n", |
| 308 | + " .select(\"student_id\", \"student_name\") \\\n", |
| 309 | + " .orderBy(\"student_id\").show()" |
| 310 | + ] |
166 | 311 | }
|
167 | 312 | ],
|
168 | 313 | "metadata": {
|
169 | 314 | "application/vnd.databricks.v1+notebook": {
|
170 |
| - "computePreferences": null, |
| 315 | + "computePreferences": { |
| 316 | + "hardware": { |
| 317 | + "accelerator": null, |
| 318 | + "gpuPoolId": null, |
| 319 | + "memory": null |
| 320 | + } |
| 321 | + }, |
171 | 322 | "dashboards": [],
|
172 | 323 | "environmentMetadata": {
|
173 | 324 | "base_environment": "",
|
174 |
| - "environment_version": "1" |
| 325 | + "environment_version": "2" |
175 | 326 | },
|
176 | 327 | "inputWidgetPreferences": null,
|
177 | 328 | "language": "python",
|
|
0 commit comments