title: Python: extracts the same values across years
body: <p>question: Write a function that extracts the same values across years and calculates the differences between consecutive values to show if number of births is increasing or decreasing. For example, how did the number of births on Saturday change each year between 1994 and 2003?</p>
  
  <p>I have extracted data day of the week wise and year wise too (see the codes below). However, I need it as: Year / day of the week / number of births. After getting this output I want to see day wise change in years (Births on Sundays in 1995 compared to births on Sundays in 1994). </p>
  
  <p>Source: (<a href="https://raw.githubusercontent.com/fivethirtyeight/data/master/births/US_births_1994-2003_CDC_NCHS.csv" rel="nofollow noreferrer">https://raw.githubusercontent.com/fivethirtyeight/data/master/births/US_births_1994-2003_CDC_NCHS.csv</a>)</p>
  
  <p>for example:</p>
  
  <pre><code>         {1994, 1, 124567,
            1994, 2, 524652...
        ....2003, 7, 452456} 
  </code></pre>
  
  <p>...earlier work...</p>
  
  <p><strong>code: DAY OF THE WEEK WISE</strong></p>
  
  <pre><code>def dow_births(lst_of_lsts):
      birth_per_day = dict()
  
      for row in lst_of_lsts:
          day_of_week = row[3]
          births = row[4]
  
          if day_of_week in birth_per_day:
              birth_per_day[day_of_week] += births
          else:
              birth_per_day[day_of_week] = births
  
      return birth_per_day  
  
  cdc_day_births = dow_births(cdc_list)  
  </code></pre>
  
  <p><strong>input:</strong></p>
  
  <pre><code>cdc_day_births
  </code></pre>
  
  <p><strong>output:</strong></p>
  
  <pre><code>{1: 5789166,
   2: 6446196,
   3: 6322855,
   4: 6288429,
   5: 6233657,
   6: 4562111,
   7: 4079723}
  </code></pre>
  
  <p><strong>code: YEAR WISE</strong></p>
  
  <pre><code>def calc_counts(data, column):
      sum_dict = dict()
  
      for row in data:
          column_value = row[column]
          births = row[4]
          if column_value in sum_dict:
              sum_dict[column_value] += births
          else:
              sum_dict[column_value] = births
  
      return sum_dict
  </code></pre>
  
  <p><strong>Input:</strong></p>
  
  <pre><code>cdc_year_births
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>{1994: 3952767,
   1995: 3899589,
   1996: 3891494,
   1997: 3880894,
   1998: 3941553,
   1999: 3959417,
   2000: 4058814,
   2001: 4025933,
   2002: 4021726,
   2003: 4089950}
  </code></pre>