Question: Python 3 code. Thank you. (example how the function would work) >>> print(raw_data[0]) [[4, 17, 67, 76, 51, 28, 3, 1, 0, 0, 0, 1],

Python 3 code. Thank you.

(example how the function would work)

>>> print(raw_data[0]) [[4, 17, 67, 76, 51, 28, 3, 1, 0, 0, 0, 1], [0, 1, 8, 28, 69, 129, 83, 55, 19, 4, 0, 0], [0, 0, 0, 8, 86, 55, 0, 0, 0, 0, 0, 0], [0, 0, 1, 10, 24, 43, 64, 58, 58, 26, 12, 0], [0, 0, 2, 15, 56, 116, 51, 8, 0, 0, 0, 0]] >>> aligned_counts = align_counts(raw_data[0]) >>> print(aligned_counts) [[0, 1, 4, 17, 67, 76, 51, 28, 3, 1, 0, 0], [0, 1, 8, 28, 69, 129, 83, 55, 19, 4, 0, 0], [0, 0, 0, 0, 8, 86, 55, 0, 0, 0, 0, 0], [0, 1, 10, 24, 43, 64, 58, 58, 26, 12, 0, 0], [0, 0, 2, 15, 56, 116, 51, 8, 0, 0, 0, 0]]

Python 3 code. Thank you. (example how the function would work) >>>

The timing of a flu outbreak can vary from year to year- some years they may occur early in winter, and other years they may occur later in the year. To get a better idea of what a typical flu outbreak looks like, we need to 'align' the case counts for each year. Aligning the case counts means shifting the series for each year left or right so that their 'peaks' (the month in which the maximum count value occurs) line up with each other Write a function align_counts(raw_counts) that takes anested list of raw counts as inputs (i.e. the first item in the 3-tuple returned by parse_data) and returns a nested list of aligned counts. To align the case counts, you should: Identify for each year, the month in which the outbreak reached its "peak" The peak is the month in which the maximum number of cases occurred for that year. identify the median month of peak occurence: for example, if the flu seasons over five years peak in months APR, MAY JUN, JUN and JUL, then the median month of peak occurrence is JUN . shift the series for each year left or right so that the peak for that year is aligned with the median month of peak occurence Assumptions . You may assume that we are always considering five years worth of data (2010-2014) If the maximum number of cases occurs in more than one month in a given year, you may assume that the peak is the first month with this number of cases When aligning case counts, you may treat each year as fit' wraps around' that is any counts that are shifted before the first month of the year can be treated as occurring at the end of that same year, and any counts that are shifted after the last month of the year can be treated as having occurred at the beginning of that same year, as has occurred for the first year in the example shown below

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!