I want a faster way for Pandas python to calculate number of occurrences of each element of listA in listB and make the number of counts into listC. for example
listA = [1,2,3,4,5,6,7]
listB = [1,1,5,4,8,3,4,7,9,2,1,4,7,6,2,4,5,6,3]
output:
listC = [3,2,2,4,2,2,2]
listA has 800 000 elements and listB has 2million elements. I am using the following code but it takes too long to process using Pandas.
listC =[listB.count(x) for x in listA]