Is there any way to count how many time specific patterns occurred in DataFrame?

53 Views Asked by At

I have DataFrame which looks like this :

    A      B       

0   10    jacket 
1   10    T-shirt
2   20    jacket
3   20    hoodie
4   10    jacket 
5   10    T-shirt
6   20    jacket
7   20    hoodie
.
.
.

It is obviously clear that there is a pattern in every two rows in this DataFrame, which are :

first_pattern = ('A' = 10 & 'B' = jacket) with ('A' = 10 & 'B' = T-shirt)

second_patterns = ('A' = 20 & 'B' = jacket) with ('A' = 20 & 'B' = hoodie)

now I want to count how many times have these patterns occurred.

I expect a result like this :

count_first_pattern = 35
count_second_pattern = 82

I would really appreciate your help.

Many thanks

0

There are 0 best solutions below