Interview Query

Over 100 Dollars
Go to question details page

You’re given two dataframes: transactions and products.

The transactions dataframe contains transaction ids, product ids, and the total amount of each product sold.

The products dataframe contains product ids and prices.

Write a function to return a dataframe containing every transaction with a total value of over $100. Include the total value of the transaction as a new column in the dataframe.

Example:

Input:

import pandas as pd

transactions = {"transaction_id" : [1, 2, 3, 4, 5], "product_id" : [101, 102, 103, 104, 105], "amount" : [3, 5, 8, 3, 2]}

products = {"product_id" : [101, 102, 103, 104, 105], "price" : [20.00, 21.00, 15.00, 16.00, 52.00]}

df_transactions = pd.DataFrame(transactions)

df_products = pd.DataFrame(products)

Output:

transaction_id product_id amount total_value
2 102 5 105.00
3 103 8 120.00
5 105 2 104.00
Good job, keep it up!

50%

Completed

You have 15 sections remaining on this learning path.

Advance your learning journey! Go Premium and unlock 40+ hours of specialized content.