title: create pivot table in pandas using count of occurrence of value
body: <p>I'm attempting to create cross-table / pivot table in pandas:</p>
  
  <pre><code>import pandas as pd
  import numpy as np
  
  df = pd.DataFrame({'foo': ['one', 'one', 'one', 'two', 'two','two'],'bar': ['A', 'A', 'C', 'B', 'B', 'C']})
  </code></pre>
  
  <p>however my attempts come up as:</p>
  
  <pre><code>pd.pivot(df, index='foo', columns='bar')
  </code></pre>
  
  <blockquote>
    <p>TypeError: pivot_simple() got multiple values for argument 'index'</p>
  </blockquote>
  
  <p>and the second:</p>
  
  <pre><code>pd.pivot_table(data = df, values = 'bar', index = 'bar', columns = 'foo', aggfunc=lambda x: np.count_nonzero(x))
  
  foo one two
  bar     
  A   4.0 NaN
  B   NaN 4.0
  C   2.0 2.0
  </code></pre>
  
  <p>The output I'm looking to achieve is the below:</p>
  
  <pre><code>        A   B   C
  one     2       1
  two        2    1
  </code></pre>