title: Transforming pandas dataframe into a summary table based on a list of values
body: <p>I am trying to create a summary table from a dataframe that looks like below example. The columns have a set list of unique values.</p>
  
  <pre class="lang-py prettyprint-override"><code>tdf = pd.DataFrame({"A": ["ind1", "ind2", "ind1", "ind3", "ind3", "ind1", "ind1"],
                     "B": ["ind3", "ind1", "ind3", "ind1", "ind1","ind3", "ind2"],
                     "C": ["ind1","ind1","ind2","ind2","ind3","ind3","ind3"],
                     "D": ["ind3","ind1","ind2","ind3","ind2","ind1","ind3"],
                     "E": ["ind1","ind3","ind1","ind1","ind2","ind2","ind2"]})
  </code></pre>
  
  <p>I'd then need to create a new table-like object that has a header that correspond to the columns and 3 rows with frequency counts of the set index values. </p>
  
  <pre class="lang-py prettyprint-override"><code>setvalues = ['ind1','ind2','ind3']
  
  result = pd.DataFrame({"A": [4,1,2],
                     "B": [3,1,3],
                     "C": [2,2,3],
                     "D": [2,2,3],
                     "E": [3,3,1]})
  </code></pre>
  
  <p>I tried pivot tables but it wasn't returning the required format. In Excel I could just set the index values and do a simple COUNTIF on the columns but I am struggling to implement it in Python.</p>