BuildlyBuildly
DashboardExercisesProfileHelp
Back to all

Practice: Merge & Concat

Drills tagged with this skill, unpassed first. Pass them all to mark the skill ready for scenarios.

Module 2: Data Analytics

0/3 done
Exercises (0/3)
  • 1
    Inner Join Two Tables
    Context. Combine an orders table with a customers table so each order row picks up the customer's name. Your task. Write attach_customer_name(orders, customers) that returns an inner-joined DataFrame on customer_id. Only customers present in both tables are kept. Example. orders has customer_ids 1, 2, 3; customers has 1, 2, 4 → result has only rows for IDs 1 and 2. Notes. Inner join. Result preserves the orders-table row order for matched rows. No overlap → empty DataFrame.
    7 min· 10 XP
  • 2
    Left Join with Fallback Value
    Context. Stack of orders, but the customer table doesn't have every customer. Keep all orders; fill missing names with "Unknown". Your task. Write attach_or_unknown(orders, customers) that left-joins on customer_id and replaces missing names with "Unknown". Example. orders for customers 10, 20, 30; customers has only 10, 20 → 3 rows, with name="Unknown" for the order with customer 30. Notes. Same row order as orders. Every order matched → no "Unknown" substitution.
    7 min· 10 XP
  • 3
    Stack DataFrames Vertically
    Context. Daily sales come in as separate DataFrames; combine them into a single table. Your task. Write combine(dfs) that takes a list of DataFrames and returns them concatenated vertically with the index reset to 0..N-1. Example. combine([df_mon, df_tue, df_wed]) → all rows stacked, re-indexed. Notes. Empty list → empty DataFrame (pd.concat([]) raises, so handle that). All dfs share the same columns.
    7 min· 10 XP