title: Dictionary comprehension to calculate statistics across dict of dicts for each key in inner dicts
body: <p>I have a dictionary like this:</p>
  
  <pre><code>property2region2value = {
      'countryA':{
          'a': 24,
          'b': 56,
          'c': 78
      },
      'countryB':{
          'a': 3,
          'b': 98
      },
      'countryC':{
          'a': 121,
          'b': 12121,
          'c': 12989121,
          'd':16171
      },
      'countryD':{
          'a': 123,
          'b': 1312,
          'c': 1231
      },
      'countryE':{
          'a': 1011,
          'b': 1911
      },
      'countryF'{
          'a': 1433,
          'b': 19829,
          'c': 1132,
          'd':1791
      }
  }
  </code></pre>
  
  <p>And I am trying to create multiple dictionaries that each contains certain statistics about the master dictionary (min, max, std etc) about all the values for that property (<code>a','b','c</code> etc) across all the countries (e.g. <code>countryA, countryB</code>) etc.</p>
  
  <p>So for example: <code>{'a': min of 'a' across all countries, 'b': min of 'b' across all countries....}</code> might be one dictionary.</p>
  
  <p>At the moment, I do a huge loop of code which a) isn't efficient and b) doesn't allow me to quickly calculate statistics e.g. using <code>np.min()</code> or <code>np.max()</code> as functions in numpy.</p>
  
  <p>How can I use dictionary comprehension to achieve this? Current code for calculating <code>min</code> and <code>max</code>:</p>
  
  <pre><code>for country, property2value in property2region2value.items():
      for property,value in property2value.items():
          if property not in property2rangeMax:
              property2rangeMax[property] = 0
          if property2rangeMax[property]&lt;value:
              property2rangeMax[property]=value
          if property not in property2rangeMin:
              property2rangeMin[property] = 0
          if property2rangeMin[property]&gt;value:
              property2rangeMin[property] = value
  </code></pre>