From 0b9a19dfdd494e5cdbf28b5c7ead6842effcdbc4 Mon Sep 17 00:00:00 2001 From: shthapa Date: Fri, 9 May 2025 11:34:43 -0400 Subject: [PATCH] Assignment-2 complete --- 02_activities/assignments/assignment_2.ipynb | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/02_activities/assignments/assignment_2.ipynb b/02_activities/assignments/assignment_2.ipynb index b98c21c65..dd8d0e239 100644 --- a/02_activities/assignments/assignment_2.ipynb +++ b/02_activities/assignments/assignment_2.ipynb @@ -95,8 +95,10 @@ "\n", "with open(all_paths[0], 'r') as f:\n", " # YOUR CODE HERE: Use the readline() or readlines() method to read the .csv file into a variable\n", - " \n", - " # YOUR CODE HERE: Iterate through the variable using a for loop and print each row for inspection" + " print(f.readlines())\n", + " # YOUR CODE HERE: Iterate through the variable using a for loop and print each row for inspection\n", + " for row in f:\n", + " print(row.strip())" ] }, { @@ -145,13 +147,13 @@ " # Implement the specific operation based on the 'operation' argument\n", " if operation == 'mean':\n", " # YOUR CODE HERE: Calculate the mean (average) number of flare-ups for each patient\n", - "\n", + " summary_values = np.mean(data, axis=1)\n", " elif operation == 'max':\n", " # YOUR CODE HERE: Calculate the maximum number of flare-ups experienced by each patient\n", - "\n", + " summary_values = np.max(data, axis=1)\n", " elif operation == 'min':\n", " # YOUR CODE HERE: Calculate the minimum number of flare-ups experienced by each patient\n", - "\n", + " summary_values = np.min(data, axis=1)\n", " else:\n", " # If the operation is not one of the expected values, raise an error\n", " raise ValueError(\"Invalid operation. Please choose 'mean', 'max', or 'min'.\")\n", @@ -261,8 +263,9 @@ "\n", "def detect_problems(file_path):\n", " #YOUR CODE HERE: Use patient_summary() to get the means and check_zeros() to check for zeros in the means\n", - "\n", - " return" + " \n", + " means = patient_summary(file_path, 'mean') # checking each patient's mean inflammation\n", + " return check_zeros(means)" ] }, {