Multi-Table Joins and String Splitting
Beginner Mode

Start your terminal to use beginner mode.

Objective

You work as a data analyst for a multinational flooring company, "Floors 'R' Us". Your task is to process and analyze data from three different sources - the customers, orders, and products tables.

Task

The full_name column in the customers DataFrame is a combination of the customer's first and last name, separated by a space. The product_info column in the products DataFrame contains the type and color of the product, separated by a comma.

Write a function that:

  1. Joins the three tables so each order has its associated customer and product information.
  2. Splits the full_name column into first_name and last_name columns.
  3. Splits the product_info column into product_type and product_color columns.

Save your resulting DataFrame as result_df. Ensure the output exactly matches the requested Output Schema, containing all the orders.

File Path

  • Customers Dataset: /home/interview/customers.csv
  • Orders Dataset: /home/interview/orders.csv
  • Products Dataset: /home/interview/products.csv
  • Starter script: /home/interview/floors_r_us.py

Schema

customers.csv

column_name data_type
customer_id int
full_name string
location string

orders.csv

column_name data_type
order_id int
customer_id int
product_id int
quantity int

products.csv

column_name data_type
product_id int
product_info string

Expected Output Schema

column_name data_type
order_id int
customer_id int
first_name string
last_name string
location string
product_id int
product_type string
product_color string
quantity int

Example

Given this sample input:

customers

customer_id full_name location
1 John Doe Texas
2 Jane Smith California

orders

order_id customer_id product_id quantity
1001 1 101 5
1002 2 102 2

products

product_id product_info
101 Carpet,Red
102 Tile,Blue

The expected output would be:

order_id customer_id first_name last_name location product_id product_type product_color quantity
1001 1 John Doe Texas 101 Carpet Red 5
1002 2 Jane Smith California 102 Tile Blue 2

Terminal requires a larger screen

Open this page on a desktop or tablet (≥ 768px) to launch the terminal and practice hands-on.

Linux Terminal Environment

Write and execute your solution in the terminal below.

Sign In

Track

Question Difficulty Company Access
Need more practice in this area? Explore more questions →