benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf bbccead7-710e-5469-a550-680851af53a4

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import pandas as pd
import collections

def task_func(df):
    """
    Generate a sales report from a DataFrame, excluding duplicate customer names. 
    The report includes total sales and the most popular sales category.

    Parameters:
    df (DataFrame): A pandas DataFrame with columns 'Customer', 'Category', and 'Sales'.

    Returns:
    dict: A dictionary with keys 'Total Sales' (sum of sales) and 'Most Popular Category' (most frequent category).

    Requirements:
    - pandas
    - collections

    Raises:
    - The function will raise a ValueError is input df is not a DataFrame.

    Note:
    - The function would return the first category in alphabetical order for "Most Popular Category' in the case of tie

    Example:
    >>> data = pd.DataFrame([{'Customer': 'John', 'Category': 'Electronics', 'Sales': 500}, {'Customer': 'Mary', 'Category': 'Home', 'Sales': 300}])
    >>> report = task_func(data)
    >>> print(report)
    {'Total Sales': 800, 'Most Popular Category': 'Electronics'}
    """

instruct prompt

Generate a sales report from a DataFrame, excluding duplicate customer names. The report includes total sales and the most popular sales category.
Note that: The function would return the first category in alphabetical order for "Most Popular Category' in the case of tie
The function should raise the exception for: The function will raise a ValueError is input df is not a DataFrame.
The function should output with:
    dict: A dictionary with keys 'Total Sales' (sum of sales) and 'Most Popular Category' (most frequent category).
You should write self-contained code starting with:

Code

import pandas as pd
import collections
def task_func(df):

code prompt

Code

import pandas as pd
import collections
def task_func(df):

entry point

task_func

libs

  • pandas
  • collections

Discussion

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

Official source

initial import