title: How to have a cross tabulation for categorical data in Pandas (Python)?
body: <p>I have the following code for example. </p>
  
  <pre><code>df = pd.DataFrame(dtype="category")
  df["Gender"]=np.random.randint(2, size=100)
  df["Q1"] = np.random.randint(3, size=100)
  df["Q2"] = np.random.randint(3, size=100)
  df["Q3"] = np.random.randint(3, size=100)
  df[["Gender", "Q1", "Q2", "Q3"]] = df[["Gender", "Q1", "Q2", "Q3"]].astype('category')
  pd.pivot_table(data=df,index=["Gender"])
  </code></pre>
  
  <p>I want to have a pivot table with percentages over gender for all the other columns. Infact, like the follwing.</p>
  
  <p><a href="https://i.stack.imgur.com/hniAu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hniAu.png" alt="enter image description here"></a></p>
  
  <p>How to achieve this?</p>
  
  <p>The above code gives an error saying that 
  <code>No numeric types to aggregate</code></p>
  
  <p>I dont have any numerical columns. I just want to find the frequency in each category under male and female and find the percentage of them over male and female respectively. </p>