Skip to content

Commit 4cd3771

Browse files
committed
Update Q2
1 parent 8f254c6 commit 4cd3771

1 file changed

Lines changed: 20 additions & 16 deletions

File tree

02_activities/assignments/assignment_2.ipynb

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
},
7373
{
7474
"cell_type": "code",
75-
"execution_count": 1,
75+
"execution_count": 3,
7676
"metadata": {
7777
"id": "n0m48JsS-nMC"
7878
},
@@ -260,16 +260,16 @@
260260
},
261261
{
262262
"cell_type": "code",
263-
"execution_count": 14,
263+
"execution_count": 8,
264264
"metadata": {
265265
"id": "82-bk4CBB1w4"
266266
},
267267
"outputs": [],
268268
"source": [
269269
"import numpy as np\n",
270270
"\n",
271-
"def patient_summary(file_path, operation):\n",
272-
" data = np.loadtxt(fname=file_path, delimiter=',') # Load the data from the file\n",
271+
"def patient_summary(all_paths, operation) -> np.ndarray:\n",
272+
" data = np.loadtxt(fname=all_paths, delimiter=',') # Load the data from the file\n",
273273
" axis = 1 # This specifies that the operation should be done for each row (patient)\n",
274274
"\n",
275275
" # Implement the specific operation based on the 'operation' argument\n",
@@ -293,16 +293,12 @@
293293
" f\"from data with shape {data.shape}.\"\n",
294294
" )\n",
295295
" return summary_values\n",
296-
" \n",
297-
"\n",
298-
"\n",
299-
" \n",
300296
"\n"
301297
]
302298
},
303299
{
304300
"cell_type": "code",
305-
"execution_count": 12,
301+
"execution_count": 10,
306302
"metadata": {
307303
"id": "3TYo0-1SDLrd"
308304
},
@@ -311,24 +307,32 @@
311307
"name": "stdout",
312308
"output_type": "stream",
313309
"text": [
314-
"60\n",
315-
"60\n",
316-
"60\n"
310+
"[0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
311+
" 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.\n",
312+
" 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0.]\n",
313+
"[5.45 5.425 6.1 5.9 5.55 6.225 5.975 6.65 6.625 6.525 6.775 5.8\n",
314+
" 6.225 5.75 5.225 6.3 6.55 5.7 5.85 6.55 5.775 5.825 6.175 6.1\n",
315+
" 5.8 6.425 6.05 6.025 6.175 6.55 6.175 6.35 6.725 6.125 7.075 5.725\n",
316+
" 5.925 6.15 6.075 5.75 5.975 5.725 6.3 5.9 6.75 5.925 7.225 6.15\n",
317+
" 5.95 6.275 5.7 6.1 6.825 5.975 6.725 5.7 6.25 6.4 7.05 5.9 ]\n",
318+
"[18. 18. 19. 17. 17. 18. 17. 20. 17. 18. 18. 18. 17. 16. 17. 18. 19. 19.\n",
319+
" 17. 19. 19. 16. 17. 15. 17. 17. 18. 17. 20. 17. 16. 19. 15. 15. 19. 17.\n",
320+
" 16. 17. 19. 16. 18. 19. 16. 19. 18. 16. 19. 15. 16. 18. 14. 20. 17. 15.\n",
321+
" 17. 16. 17. 19. 18. 18.]\n"
317322
]
318323
}
319324
],
320325
"source": [
321326
"# Test it out on the data file we read in and make sure the size is what we expect i.e., 60\n",
322327
"# Your output for the first file should be 60\n",
323328
"data_min = patient_summary(all_paths[0], 'min')\n",
324-
"print(len(data_min))\n",
329+
"print(data_min)\n",
325330
"\n",
326331
"data_mean = patient_summary(all_paths[0], 'mean')\n",
327-
"print(len(data_mean))\n",
332+
"print(data_mean)\n",
328333
"\n",
329334
"data_max = patient_summary(all_paths[0], 'max')\n",
330-
"print(len(data_max))\n",
331-
"\n"
335+
"print(data_max)\n"
332336
]
333337
},
334338
{

0 commit comments

Comments
 (0)