Skip to content

Commit b650ce1

Browse files
authored
Refactor dataset reading and loop for clarity
1 parent 39a381d commit b650ce1

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

02_activities/assignments/assignment_2.ipynb

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,10 @@
9595
"\n",
9696
"with open(all_paths[0], 'r') as f:\n",
9797
" # YOUR CODE HERE: Use the readline() or readlines() method to read the .csv file into a variable\n",
98-
" \n",
99-
" dataset = f.readlines(),
98+
" dataset = f.readlines()\n"
10099
" # reads only first item inflammation_01.csv
101100
" # YOUR CODE HERE: Iterate through the variable using a for loop and print each row for inspection"
102-
" for x in dataset:\n",
101+
" for row in dataset:\n",
103102
" print(x)"
104103
]
105104
},
@@ -150,15 +149,12 @@
150149
" if operation == 'mean':\n",
151150
" # YOUR CODE HERE: Calculate the mean (average) number of flare-ups for each patient\n",
152151
" summary_values = np.mean(data, axis=ax)\n",
153-
"\n",
154152
" elif operation == 'max':\n",
155153
" # YOUR CODE HERE: Calculate the maximum number of flare-ups experienced by each patient\n",
156154
" summary_values = np.max(data, axis=ax)\n",
157-
"\n",
158155
" elif operation == 'min':\n",
159156
" # YOUR CODE HERE: Calculate the minimum number of flare-ups experienced by each patient\n",
160157
" summary_values = np.min(data, axis=ax)\n",
161-
"\n",
162158
" else:\n",
163159
" # If the operation is not one of the expected values, raise an error\n",
164160
" raise ValueError(\"Invalid operation. Please choose 'mean', 'max', or 'min'.\")\n",
@@ -271,8 +267,6 @@
271267
" mean_data = patient_summary(file_path, 'mean')\n",
272268
" result = check_zeros(mean_data)\n",
273269
" return result"
274-
"\n",
275-
" return"
276270
]
277271
},
278272
{

0 commit comments

Comments
 (0)