title: table() equivalent function(from R) in Python
body: <p>I am trying to get the table() equivalent function(from R) in Python.</p>
  
  <p>I have a table :</p>
  
  <pre><code>+-----+--------+
  |  Sr | Gender |
  +-----+--------+
  | 123 |    M   |
  +-----+--------+
  | 124 |    M   |
  +-----+--------+
  | 126 |    M   |
  +-----+--------+
  | 127 |    F   |
  +-----+--------+
  | 128 |    F   |
  +-----+--------+
  </code></pre>
  
  <p>Expected output :</p>
  
  <pre><code>+---+---+
  | M | F |
  +---+---+
  | 3 | 2 |
  +---+---+
  </code></pre>
  
  <p>in R it could be easily achieved by <code>table(df$Gender)</code>  </p>
  
  <p>But not sure how to achieve this in Python. I have tried crosstab() and pivot_table() but not able to get the exact syntax. </p>