PracHub
QuestionsPremiumLearningGuidesInterview PrepNEWCoaches

Quick Overview

This question evaluates proficiency in data manipulation using pandas, including relational joins and aggregation to produce country-level summary statistics like totals and averages.

  • Medium
  • Amazon
  • Data Manipulation (SQL/Python)
  • Data Scientist

Create Country-Level Spend Report Using Pandas

Company: Amazon

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

users +---------+---------+ | user_id | country | +---------+---------+ | 1 | US | | 2 | CA | | 3 | US | +---------+---------+ ​ transactions +--------+---------+--------+ | txn_id | user_id | amount | +--------+---------+--------+ | 10 | 1 | 30.5 | | 11 | 1 | 15.0 | | 12 | 2 | 20.0 | +--------+---------+--------+ ##### Scenario E-commerce analytics team has separate user and transaction tables and needs country-level spend reporting. ##### Question Using pandas, merge the users and transactions DataFrames on user_id; keep only rows with matching users. Group the merged result by country, computing total and average amount, and return a DataFrame sorted by total spend descending. ##### Hints Apply pandas merge, groupby, agg, and sort_values correctly.

Quick Answer: This question evaluates proficiency in data manipulation using pandas, including relational joins and aggregation to produce country-level summary statistics like totals and averages.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Find recommended friend pairs by shared songs - Amazon (medium)
  • Find recommended friend pairs by shared listening - Amazon (easy)
  • Write SQL window functions for D7 retention - Amazon (medium)
  • Find daily first-order merchants with SQL - Amazon (Medium)
  • Design student–course data models and SQL - Amazon (Medium)