benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf 6a727776-2050-5c88-b999-9c86425f2067
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import csv
import collections
import operator
def task_func(csv_file_path):
"""
Find the best-selling product from a given CSV file with sales data.
This function parses a CSV file assumed to have a header followed by rows containing
two columns: 'product' and 'quantity'. It computes the total sales per product and
determines the product with the highest cumulative sales. The CSV file must include
at least these two columns, where 'product' is the name of the product as a string
and 'quantity' is the number of units sold as an integer.
Args:
csv_file_path (str): The file path to the CSV file containing sales data.
Returns:
str: The name of the top-selling product based on the total quantity sold.
Requirements:
- csv
- collections
- operator
Example:
>>> task_func("path/to/sales.csv")
'Product ABC'
"""
instruct prompt
Find the best-selling product from a given CSV file with sales data. This function parses a CSV file assumed to have a header followed by rows containing two columns: 'product' and 'quantity'. It computes the total sales per product and determines the product with the highest cumulative sales. The CSV file must include at least these two columns, where 'product' is the name of the product as a string and 'quantity' is the number of units sold as an integer. Args: csv_file_path (str): The file path to the CSV file containing sales data.
The function should output with:
str: The name of the top-selling product based on the total quantity sold.
You should write self-contained code starting with:
Code
import csv
import collections
import operator
def task_func(csv_file_path):
code prompt
Code
import csv
import collections
import operator
def task_func(csv_file_path):
entry point
task_func
libs
- operator
- csv
- collections
Discussion
No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.
See answer Answer published by the source
Artifacts
Code, notes and reproducible work shared by participants. Files are served from a separate origin.
No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.
Source and history
initial import