title: working with elements of dict of lists
body: <p>I have a dataset which is a dict which consisting of lists (number of elements in each list is fixed, but the dict itself has a large number of entries)</p>
  
  <p>E.g.:</p>
  
  <pre><code>d1 = {0: [1,2,3], 
        1: [2,3,4], 
        2: [3,4,5], 
        3: [4,5,6], 
        4: [5,6,7] }
  </code></pre>
  
  <p>now i need to create a dict such that: </p>
  
  <pre><code>d_required = { 0: [d1[0][0]/1, d1[0][1]/1, d1[0][2]/1],
                 1: [(d1[0][0] + d1[1][0])/2, (d1[0][1] + d1[1][1])/2, (d1[0][2] + d1[1][2])/2],
                 2: [(d1[0][0] + d1[1][0] + d1[2][0])/3, (d1[0][1] + d1[1][1] + d1[2][1])/3, (d1[0][2] + d1[1][2] + d[2][2])/3],
                 3: [(d1[0][0] + d1[1][0] + d1[2][0] +d1[3][0])/4, (d1[0][1] + d1[1][1] + d1[2][1] + d1[3][1])/4, (d1[0][2] + d1[1][2] + d[2][2] + d[3][2])/4], 
                 4: [(d1[0][0] + d1[1][0] + d1[2][0] + d1[3][0] + d1[4][0])/5, (d1[0][1] + d1[1][1] + d1[2][1] + d1[3][1] + d1[4][1])/5, (d1[0][2] + d1[1][2] + d[2][2] + d[3][2] + d1[4][2])/5]}
  </code></pre>
  
  <p>i.e, the averaging window increases as I move down the dict.
  I am unable to get my head around to code this and am seeking any form of help.</p>
  
  <p>Here is my attempt (which doesnt seem like it is doing the right thing :( )</p>
  
  <pre><code>def weirdProcessing(dataDict):
      resultDict = {}
  
      for d in sorted(dataDict.keys()):
          l = dataDict[d]
          res = []
          for i in range(len(l)):
              tempSum = 0
              for k in range(d):
                  tempSum += dataDict[k][i] 
  
              res.append(tempSum/float(d+1))
          if d == 0:
              resultDict[d] = copy.deepcopy(dataDict[d])
          else:
              resultDict[d] = res
  
      return resultDict
  </code></pre>