P14PythonIntermediateImplement12 min

Aggregate Transactions by Customer

Aggregate transaction records into customer-level revenue and order counts.

#aggregation#dictionaries#transactions

Scenario

A daily export is a list of transaction dictionaries, and the account team needs a compact customer summary.

Problem statement

Create one summary per customer with completed-order revenue and count.

Your Task

  1. Ignore non-completed transactions.
  2. Track both total revenue and order count.
  3. Keep the output ready for later tabular analysis.

Input

transactions = [{'customer': 'Asha', 'amount': 120, 'status': 'completed'}, {'customer': 'Asha', 'amount': 80, 'status': 'refunded'}]

Related Concepts

Data grainRecord processingBusiness rules

Ready to count this problem?

Mark it complete when you have reasoned through the solution in your own words.