Interview Query
Back to Data Science Interview
Data Science Interview

Data Science Interview

92 of 257 Completed

1m read
5m read
2m read
1m read
5m read
4m read
Question
Question
Question
Question
Question

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!

35%

Completed

You have 165 sections remaining on this learning path.

Loading pricing options.