Lumen interview question

Python Pandas question to manipulate the data SQL Group by the question