Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions 02_activities/assignments/assignment_2.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,13 @@
"outputs": [],
"source": [
"with open(all_paths[0], 'r') as f:\n",
" # YOUR CODE HERE: Use the readline() or readlines() method to read the .csv file into 'contents'\n",
" \n",
" # YOUR CODE HERE: Iterate through 'contents' using a for loop and print each row for inspection"
"print(f.readline()) \n",
" \n",

"with open(all_paths[0], 'r') as f:\n",
"for line in f:\n",
"print(line) \n",
" \n"
]
},
{
Expand Down Expand Up @@ -146,15 +150,19 @@
" data = np.loadtxt(fname=file_path, delimiter=',')\n",
" ax = 1 # this specifies that the operation should be done for each row (patient)\n",
"\n",
" # 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",
" result = np.mean(data, axis=1)\n",
" return result\n",
"\n",
" elif operation == 'max':\n",
" # YOUR CODE HERE: calculate the maximum number of flare-ups experienced by each patient\n",
" result = np.max(data, axis=1)\n",

" return result\n",
"\n",
" elif operation == 'min':\n",
" # YOUR CODE HERE: calculate the minimum number of flare-ups experienced by each patient\n",
" result = np.max(data, axis=1)\n",

" return result\n",
"\n",
" else:\n",
" # if the operation is not one of the expected values, raise an error\n",
Expand Down Expand Up @@ -264,7 +272,12 @@
"# Define your function `detect_problems` here\n",
"\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",
" mean_inflammations = patient_summary(file_path, 'mean')\n",

" if check_zeros(mean_inflammations):\n",
" return True\n",
" else:\n",
" return False\n",
"\n",
" return"
]
Expand Down