benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 60a08104-c68a-5ab6-b8ad-265e1772a589

Problem

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

complete prompt

import pandas as pd
import numpy as np
import random
from random import randint, seed

# Constants
CATEGORIES = ['Electronics', 'Clothing', 'Home & Kitchen', 'Books', 'Toys & Games']

def task_func(mystrings, n_products, seed=0):
    """
    Create a product catalog DataFrame where each row represents a product with the following columns:
    - 'Product Name': The name of the product with spaces replaced by underscores.
    - 'Category': The category to which the product belongs.
    - 'Price': The price of the product, generated randomly based on a normal distribution with a mean of 50 and a standard deviation of 10.
    
    Parameters:
    mystrings (list of str): List of product names.
    n_products (int): Number of products to generate in the catalog.

    Returns:
    pd.DataFrame: A pandas DataFrame containing the product catalog information.

    Requirements:
    - pandas
    - numpy
    - random.randint
    - random.seed

    Constants:
    - CATEGORIES: A list of categories used to randomly assign a category to each product.

    Examples:
    >>> task_func(['Mobile Phone', 'T Shirt', 'Coffee Maker', 'Python Book', 'Toy Car'], 2)
       Product Name        Category  Price
    0   Python_Book           Books  67.64
    1  Mobile_Phone  Home & Kitchen  54.00
    >>> task_func(['Laptop', 'Sweater'], 1)
      Product Name Category  Price
    0      Sweater    Books  67.64
    """

instruct prompt

Create a product catalog DataFrame where each row represents a product with the following columns: - 'Product Name': The name of the product with spaces replaced by underscores. - 'Category': The category to which the product belongs. - 'Price': The price of the product, generated randomly based on a normal distribution with a mean of 50 and a standard deviation of 10. Constants: - CATEGORIES: A list of categories used to randomly assign a category to each product.
The function should output with:
    pd.DataFrame: A pandas DataFrame containing the product catalog information.
You should write self-contained code starting with:

Code

import pandas as pd
import numpy as np
import random
from random import randint, seed
# Constants
CATEGORIES = ['Electronics', 'Clothing', 'Home & Kitchen', 'Books', 'Toys & Games']
def task_func(mystrings, n_products, seed=0):

code prompt

Code

import pandas as pd
import numpy as np
import random
from random import randint, seed
# Constants
CATEGORIES = ['Electronics', 'Clothing', 'Home & Kitchen', 'Books', 'Toys & Games']
def task_func(mystrings, n_products, seed=0):

entry point

task_func

libs

  • pandas
  • numpy
  • 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