Practice / joins

Match on Two Keys

medium

A regional manager wants to compare each store's daily revenue against its target — but only where both numbers exist.

You have two DataFrames:

actuals

targets

Your task: join on both store and day, and return store, day, revenue, and target for the store-days that appear in both tables.

Assign your answer DataFrame to result. Row order doesn't matter.

actualsinput DataFrame

Schema
columntype
storestring
daystring
revenuedouble
Sample rows
storedayrevenue
DowntownMon8
DowntownTue4
PierMon6

targetsinput DataFrame

Schema
columntype
storestring
daystring
targetdouble
Sample rows
storedaytarget
DowntownMon7
PierMon5
HarborWed3
Expected output shape
storedayrevenuetarget· 2 rows
Hint

Pass a list of key names to on: actuals.join(targets, on=["store", "day"], how="inner"). Both keys must match for a row to survive.

Lesson refresher

This problem builds on Joins (~8 min). Pop it open in a new tab if you want a quick recap.

Loading editor…
Hit Run to execute your code and see the output here.