benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 94f4d196-6670-5217-9cbb-d9015bfae0e5

Problem

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

complete prompt

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

def task_func(animals=None, seed=42):
    """
    Create a report on the number of animals in a zoo. For each animal, generate a random count within 
    a specified range, calculate the mean, median, and standard deviation of these counts, and return 
    a DataFrame with these statistics. Additionally, generate a bar chart of the counts.

    Parameters:
    - animals (list of str, optional): List of animals to include in the report. 
        Defaults to ['Lion', 'Elephant', 'Tiger', 'Giraffe', 'Panda'].
    - seed (int, optional): Random seed for reproducibility. Defaults to 42.

    Returns:
    - DataFrame: A pandas DataFrame with columns ['Animal', 'Mean', 'Median', 'Standard Deviation'].
      Each animal's count is randomly generated 10 times within the range 1 to 100, inclusive.

    Requirements:
    - pandas
    - random
    - statistics
    - numpy

    Example:
    >>> report = task_func()
    >>> print(report)
         Animal  Mean  Median  Mode  Standard Deviation
    0      Lion  42.0    30.5    95           33.250564
    1  Elephant  44.4    41.5    12           34.197076
    2     Tiger  61.1    71.0    30           28.762649
    3   Giraffe  51.8    54.5    54           29.208903
    4     Panda  35.8    32.0    44           24.595935

    Note: The mode is not included in the returned DataFrame due to the possibility of no repeating values 
    in the randomly generated counts.
    """

instruct prompt

Create a report on the number of animals in a zoo. For each animal, generate a random count within a specified range, calculate the mean, median, and standard deviation of these counts, and return a DataFrame with these statistics. Additionally, generate a bar chart of the counts.
Note that: The mode is not included in the returned DataFrame due to the possibility of no repeating values in the randomly generated counts.
The function should output with:
    DataFrame: A pandas DataFrame with columns ['Animal', 'Mean', 'Median', 'Standard Deviation'].
    Each animal's count is randomly generated 10 times within the range 1 to 100, inclusive.
You should write self-contained code starting with:

Code

import pandas as pd
from random import randint, seed as random_seed
import statistics
import numpy as np
def task_func(animals=None, seed=42):

code prompt

Code

import pandas as pd
from random import randint, seed as random_seed
import statistics
import numpy as np
def task_func(animals=None, seed=42):

entry point

task_func

libs

  • statistics
  • 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