← All Python interview questions

Revenue by city with GroupBy

MediumPandas — GroupBySwiggyDunzo

You have an orders DataFrame and the city lead wants total revenue per city, biggest first.

Write a function revenue_by_city(df) that returns a Series indexed by city holding the summed amount, sorted from highest to lowest revenue.