in pandas i have two series of x rows and i want to add a column in which i get the rolling count of times that the value in col1 appears from the first row till the x-1 one.
The df is like this:
col1 col2
0 B A
1 B C
2 A B
3 A B
4 A C
5 B A
The desired output is
col1 col2 freq
0 B A 0
1 B C 1
2 A B 1
3 A B 2
4 A C 3 #A appears 3 times in the two columns from row 0 to 3
5 B A 4 #B appears 4 times in the two columns from row 0 to 4
Thanks in advance from a beginner, G