title: python count number of unique elements in csv column
body: <p>I'm trying to get the counts of unique items in a csv column using Python. </p>
  
  <p>Sample CSV file (has no header):</p>
  
  <pre><code>AB,asd
  AB,poi
  AB,asd
  BG,put
  BG,asd
  </code></pre>
  
  <p>I've tried this so far. </p>
  
  <pre><code>import csv
  from collections import defaultdict, Counter
  
  input_file = open('Results/1_sample.csv')
  csv_reader = csv.reader(input_file, delimiter=',')
  
  data = defaultdict(list)
  for row in csv_reader:
      data[row[0]].append(row[1])
  for k, v in data.items():
      print k
      print Counter(v)
  </code></pre>
  
  <p>This gives output in this format:</p>
  
  <pre><code>AB
  Counter({'asd': 2, 'poi': 1})
  BG
  Counter({'asd': 1, 'put': 1})
  </code></pre>
  
  <p>But I want my output to be like:</p>
  
  <pre><code>AB:2
  BG:2
  total_unique_count:3 #unique count of column[1], irrespective of the data in column[0]
  </code></pre>