title: Creating new arrays based on unique keys and condition in Python
body: <p>I'm planning to calculate large amount of data in Python instead of Excel, but I'm stuck since I know the Excel command and I have great difficulties to replicating it in Python.</p>
  
  <p>Essentially, I'd like to import CSV file, identify the location of column C, and then for all unique values in column A, sum all values in C that apply to the condition <code>1990 &lt; x &lt; 2000</code> in B </p>
  
  <pre><code>A,B,C
  9,1952,125
  2,1994,69
  3,1973,72
  5,1992,85
  1,1994,38
  1,1994,95
  4,1992,29
  8,1984,94
  </code></pre>
  
  <p>I begin with:</p>
  
  <pre><code>import csv
  with open('TestCase.txt', 'rb') as csvfile:
      reader = csv.reader(csvfile, delimiter=',')
      row1 = next(reader)
  </code></pre>
  
  <p>Instead of writing multiple <code>if</code> statements, I'd like to create new arrays, composed from 0 and 1, and then sum all values in C.</p>
  
  <p>Given another condition the result would look like this</p>
  
  <pre><code>1980&lt;x&lt;1989 94
  1990&lt;x&lt;2000 316
  </code></pre>
  
  <p>Extra bonus would be the total number of unique values in A, that represent the total sum</p>
  
  <pre><code>UniqueValues    Condition   TotalSum
  1   1980&lt;x&lt;1989 94
  4   1990&lt;x&lt;2000 316
  </code></pre>