Premium problem98. Completed Tasks for One Company

Medium Locked

users has columns user_id and company. actions has columns user_id, action_name, num_actions and action_date (datetime).

For the users belonging to company, total their num_actions for the action named "CompleteTask" within the given month (a string like "2022-01"). Return a DataFrame with columns user_id and completed covering every user at that company, including those with no matching actions, who score 0. Sort by user_id and renumber the index from 0.

Input

users =
   user_id    company
0        1  ClassPass
1        2  ClassPass
2        3      Other
actions =
   user_id   action_name  num_actions action_date
0        1  CompleteTask            2  2022-01-05
1        1  CompleteTask            3  2022-02-05
2        2      ViewPage            9  2022-01-06
3        3  CompleteTask            7  2022-01-07
company = 'ClassPass'
month = '2022-01'

Output

   user_id  completed
0        1          2
1        2          0

Premium problem

This one's part of Premium. Unlock the full Pandas track plus every other premium problem on the site.

Implement solve(...)