benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf bd999e8d-e5f7-5cb4-8a18-d17fce9d5f6b

Problem

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

complete prompt

import numpy as np
import random
import itertools
import pandas as pd

# Constants
PLANETS = [
    "Mercury",
    "Venus",
    "Earth",
    "Mars",
    "Jupiter",
    "Saturn",
    "Uranus",
    "Neptune",
]
ELEMENTS = [
    "Hydrogen",
    "Helium",
    "Oxygen",
    "Carbon",
    "Nitrogen",
    "Magnesium",
    "Silicon",
    "Iron",
    "Nickel",
]


def task_func():
    """
    Generate a DataFrame where each row contains random planet-element pairs.
    Each pair is formatted as 'Planet:Element'. The number of rows is determined by
    the number of planets, and each row will contain as many planet-element pairs as there are elements.

    Parameters:
    - None

    Returns:
    pandas.DataFrame: A DataFrame where each cell contains a string in the format 'Planet:Element'.
                      The DataFrame has a number of rows equal to the number of planets and
                      a number of columns equal to the number of elements.

    Requirements:
    - numpy
    - random
    - itertools
    - pandas

    Example:
    >>> random.seed(0)
    >>> planet_elements_table = task_func()
    >>> planet_elements_table.head(2)
              Hydrogen         Helium  ...          Iron         Nickel
    0   Uranus:Silicon  Earth:Silicon  ...  Earth:Nickel  Uranus:Helium
    1  Venus:Magnesium  Saturn:Helium  ...  Mercury:Iron   Venus:Helium
    <BLANKLINE>
    [2 rows x 9 columns]
    """

instruct prompt

Generate a DataFrame where each row contains random planet-element pairs. Each pair is formatted as 'Planet:Element'. The number of rows is determined by the number of planets, and each row will contain as many planet-element pairs as there are elements.
The function should output with:
    pandas.DataFrame: A DataFrame where each cell contains a string in the format 'Planet:Element'.
    The DataFrame has a number of rows equal to the number of planets and
    a number of columns equal to the number of elements.
You should write self-contained code starting with:

Code

import numpy as np
import random
import itertools
import pandas as pd
# Constants
PLANETS = [
    "Mercury",
    "Venus",
    "Earth",
    "Mars",
    "Jupiter",
    "Saturn",
    "Uranus",
    "Neptune",
]
ELEMENTS = [
    "Hydrogen",
    "Helium",
    "Oxygen",
    "Carbon",
    "Nitrogen",
    "Magnesium",
    "Silicon",
    "Iron",
    "Nickel",
]
def task_func():

code prompt

Code

import numpy as np
import random
import itertools
import pandas as pd
# Constants
PLANETS = [
    "Mercury",
    "Venus",
    "Earth",
    "Mars",
    "Jupiter",
    "Saturn",
    "Uranus",
    "Neptune",
]
ELEMENTS = [
    "Hydrogen",
    "Helium",
    "Oxygen",
    "Carbon",
    "Nitrogen",
    "Magnesium",
    "Silicon",
    "Iron",
    "Nickel",
]
def task_func():

entry point

task_func

libs

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