Back to questions

Manufacturing Plant (Pandas) Groupon Pandas Interview Question

Manufacturing Plant (Pandas)

Groupon Pandas Interview Question

Manufacturing Plant You are given two DataFrames related to a manufacturing company. The first, products, contains information about the products manufactured by the company, and the second, sales, contains information about the sales of these products. Write a function that returns the top 3 selling products in each product category based on the revenue generated, without any gaps in the ranking sequence. The input DataFrames have the following schemas:

Table:

Column NameType
product_idinteger
categorystring
product_namestring

Table:

Column NameType
sale_idinteger
product_idinteger
quantityinteger
revenuedouble

The output DataFrame should have the following schema:

Column NameType
categorystring
product_namestring
revenueinteger
rankinteger

Example Output:

categoryproduct_namerankrevenue
AProduct13100
BProduct4250
CProduct71150

Input

Pandas

Output