In R we can find the frequency of each item using table
.
This is an example in R:
x <- c(1,1,1,1,2,2)
y <- c("a","a","b","a","a","b")
table(x,y)
# y
#x a b
# 1 3 1
# 2 1 1
How can I implement it in python while x and y are as DataFrame? I am totally new in Python and I searched a lot but I was unable to find my answer. I should mention that I read this article but I couldn't implement it in my case?