← 返回 meta 的题目列表Python Function for Data Processing
类型:online_judge
Write a Python function process_sales_data(sales_data: List[Dict[str, Any]]) -> List[str] that receives a list of sales records, each record being a dictionary with the keys id, customer_name, amount, sale_date. The function should return a list of unique customer names with sales amounts greater than 1000 in the year 2021.
Requirements:
The input is a list where each element is a dictionary containing sales records.
The returned list of customer names should be unique.
If no records meet the criteria, return an empty list.
Do not use any library functions for parsing or handling dates.
Example:
sales_data = [
{"id": 1, "customer_name": "John Doe", "amount": 1500, "sale_date": "2021-01-15"},
{"id": 2, "customer_name": "Jane Smith", "amount": 800, "sale_date": "2021-02-20"},
{"id": 3, "customer_name": "John Doe", "amount": 900, "sale_date": "2021-03-10"},
{"id": 4, "customer_name": "Alice Johnson", "amount": 1700, "sale_date": "2021-04-30"}
]
process_sales_data(sales_data) should return: ['John Doe', 'Alice Johnson']
Example
Input
sales_data = [{"id": 1, "customer_name": "John Doe", "amount": 1500, "sale_date": "2021-01-15"},
{"id": 2, "customer_name": "Jane Smith", "amount": 800, "sale_date": "2021-02-20"},
{"id": 3, "customer_name": "John Doe", "amount": 900, "sale_date": "2021-03-10"},
{"id": 4, "customer_name": "Alice Johnson", "amount": 1700, "sale_date": "2021-04-30"}]