benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 277cf324-aa17-59c6-b78d-7b0b9725539a

Problem

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

complete prompt

from random import randint
from statistics import mean
import pandas as pd


def task_func(products_list):
    """
    This function takes in a list of product names and generates random sales data for each product over a period of
    12 months. It then calculates the average sales for each product and returns the results as a pandas DataFrame with
    columns: 'Product', 'Month 1', 'Month 2', ..., 'Month 12', 'Average Sales'..
    
    Parameters:
    products_list (list): A list of product names.
    
    Returns:
    DataFrame: A pandas DataFrame with columns: 'Product', 'Month 1', 'Month 2', ..., 'Month 12', 'Average Sales'.
    
    Requirements:
    - pandas
    - random
    - statistics
    
    Example:
    >>> products = ['Apples', 'Bananas', 'Grapes', 'Oranges', 'Pineapples']
    >>> sales_data = task_func(products)
    >>> type(sales_data)
    <class 'pandas.core.frame.DataFrame'>
    """

instruct prompt

This function takes in a list of product names and generates random sales data for each product over a period of 12 months. It then calculates the average sales for each product and returns the results as a pandas DataFrame with columns: 'Product', 'Month 1', 'Month 2', ..., 'Month 12', 'Average Sales'..
The function should output with:
    DataFrame: A pandas DataFrame with columns: 'Product', 'Month 1', 'Month 2', ..., 'Month 12', 'Average Sales'.
You should write self-contained code starting with:

Code

from random import randint
from statistics import mean
import pandas as pd
def task_func(products_list):

code prompt

Code

from random import randint
from statistics import mean
import pandas as pd
def task_func(products_list):

entry point

task_func

libs

  • statistics
  • pandas
  • random

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