searches has columns search_id, clicked (boolean) and
search_position. One search can produce several rows.
Rate every row:
1 when the result was not clicked2 when it was clicked and search_position is greater than 33 when it was clicked and search_position is 3 or lessReturn a DataFrame with columns search_id and rating holding the highest
rating each search achieved, sorted by search_id with the index renumbered
from 0. Build the rating without a Python loop.
Input
search_id clicked search_position
0 1 False 1
1 1 True 7
2 2 True 2
3 2 False 5
4 3 False 9
Output
search_id rating
0 1 2
1 2 3
2 3 1