What do you want to save?
Add Code snippet
New code examples
-
-
Python 2021-11-19 13:08:32
count occurrences of one variable grouped by another python
>>> data = pd.DataFrame({'user_id' : ['a1', 'a1', 'a1', 'a2','a2','a2','a3','a3','a3'], 'product_id' : ['p1','p1','p2','p1','p1','p1','p2','p2','p3']}) >>> count_series = data.groupby(['user_id', 'product_id']).size() >>> count_... Add solution
Best helpers
Ranking is empty