Five Rows One Eighty
A nightly report joins orders to a contacts table. orders["amount"].sum() was 100 before the join.
orders = pd.DataFrame({
"order_id": [1, 2, 3],
"customer_id": [7, 7, 9],
"amount": [50, 30, 20],
})
contacts = pd.DataFrame({ # customer 7 registered two addresses
"customer_id": [7, 7, 9],
"email": ["ana@x", "ana@y", "kim@z"],
})
report = orders.merge(contacts, on="customer_id", how="left")
print(len(report), report["amount"].sum())
What prints, and which single keyword argument would have made pandas raise instead of returning it quietly?
Sign in to answer questions and track your progress
Sign In