Problem 2: Merge Two DataFrames
Easypython
Learn the Concept: Pandas (Condensed Reference)Problem Description
Write a Python program that merges an "orders" DataFrame with a "customers" DataFrame on a shared "customer_id" column, using an inner join.
Input
Two DataFrames sharing a "customer_id" column.
Output
The merged DataFrame.
Constraints
- At least 3 rows in each DataFrame.
Example Input
textorders={"customer_id":[1,2,3],"amount":[100,150,200]} customers={"customer_id":[1,2,3],"name":["A","B","C"]}
Example Output
text(A merged DataFrame with customer_id, amount, and name columns)
Concepts Covered
pd.merge(), how="inner".
Related Problems
- Problem 1: Group and Aggregate DataEasy · pythonSolve Problem
- Problem 3: Create a Pivot TableEasy · pythonSolve Problem
- Problem 4: Apply a Custom Function to Flag ValuesEasy · pythonSolve Problem