benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 1032b5eb-3502-56ac-b505-a14cfc30590c

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

def task_func(my_list, seed=42):
    """
    Adds an item "12" to a list 'my_list', simulates sales data for different categories with an optional seed for reproducibility, and returns the data along with a bar plot.
    
    The sales data is a DataFrame with random sales figures for predefined categories.
    The categories are 'Electronics', 'Fashion', 'Home & Kitchen', 'Automotive', 'Sports'.
    
    Parameters:
    my_list (list): The input list.
    seed (int, optional): Seed for the random number generator (default is None, which means no seed).
    
    Returns:
    tuple: A tuple containing a pandas DataFrame of simulated sales data and the corresponding matplotlib Axes object.
    
    Raises:
    TypeError: If 'my_list' is not a list.

    Requirements:
    - pandas
    - numpy
    
    Example:
    >>> my_list = [1, 2, 3]
    >>> data, ax = task_func(my_list, seed=123)
    >>> print(data)
             Category  Sales
    0     Electronics   1395
    1         Fashion   1266
    2  Home & Kitchen    198
    3      Automotive    351
    4          Sports   2472
    >>> ax.get_title()  # Returns 'Category-wise Sales Data'
    'Category-wise Sales Data'
    """

instruct prompt

Adds an item "12" to a list 'my_list', simulates sales data for different categories with an optional seed for reproducibility, and returns the data along with a bar plot. The sales data is a DataFrame with random sales figures for predefined categories. The categories are 'Electronics', 'Fashion', 'Home & Kitchen', 'Automotive', 'Sports'.
The function should raise the exception for: TypeError: If 'my_list' is not a list.
The function should output with:
    tuple: A tuple containing a pandas DataFrame of simulated sales data and the corresponding matplotlib Axes object.
You should write self-contained code starting with:

Code

import pandas as pd
import numpy as np
def task_func(my_list, seed=42):

code prompt

Code

import pandas as pd
import numpy as np
def task_func(my_list, seed=42):

entry point

task_func

libs

  • pandas
  • numpy

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