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