
Data Science Interview
92 of 257 Completed
Introduction
1m read
numpy
5m read
scipy
2m read
matplotlib
1m read
pandas
5m read
sklearn
4m read
Over 100 Dollars
Question
Good Grades and Favorite Colors
Question
Generate Normal Distribution
Question
Random Seed Function
Question
Complete Addresses
Question
Over 100 Dollars
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%
CompletedYou have 165 sections remaining on this learning path.
Loading pricing options.