title: How can I get a count of occurrances in csv columns and save as a new csv containing the count in python
body: <p>I am new to python, I would really appreciate the assistance. I trie the entire day. I have a csv file containing 10 columns. I am only interested in 3 state, county and zipcode. I am trying, trying and trying to get a count of the occurrences in each column for instance CA 20000, TX 14000, and having the count result outpute to be saved in a csv files that could be easily imported into excel and further merged with geospatial files.</p>
  
  <p>I managed to select the 3 columns that I need </p>
  
  <pre><code>
  import numpy as np
  
  from tabulate import tabulate
  
  import pandas as pd 
  
  
  #Replace with path and name file in your computer
  filename = "10column.csv"
  
  # Enter the column number that you want to display between [, , ,] no space between the commas  "usecols=[3,4,5]" 
  table = np.genfromtxt(filename,delimiter=',',skip_header=0,dtype='U',usecols=[4,5,6])
  
  print(tabulate(table))
  
  #Insert the path and name of the file 
  pd.DataFrame(table).to_csv("3column.csv") 
  
  </code></pre>
  
  <p>Then I tried to count the occurrences but the output it is in the wrong format and I cannot save as csv.</p>
  
  <pre><code>
  import csv
  
  from collections import Counter
  
  
  import numpy as np
  
  my_reader = csv.reader(open("3column.csv"))
  
  #insert column number instead of the 2 "[rec[2]"
  column = [rec[2] for rec in my_reader]
  
  np.array([Counter(column)])
  
  print(np.array([Counter(column)]))
  </code></pre>
  
  <p>the result is </p>
  
  <pre><code>[Counter({'22209': 10, '20007': 5, …'})]
  </code></pre>
  
  <p>I cannot save it as csv and I would like to have on a tabulated format</p>
  
  <pre><code>zip, count
  22209, 10, 20007, 10
  </code></pre>
  
  <p>I would really appreciate your help</p>