benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 597a66dd-05e6-5e1e-a87b-127b785e0682

Problem

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

complete prompt

import pandas as pd
import random


def task_func(dictionary, item, seed):
    """
    Converts a dictionary to a pandas DataFrame and find the locations of a particular item in the resulting DataFrame.
    Counts the number of occurences and adds a random integer x, where 0 <=x < 10, to it.

    Parameters:
    dict (dictionary): The dictionary to search.
    item (str): The item to find.
    seed(int): seed for random number generation.

    Returns:
    list: A list of tuples. Each tuple contains the row-index and column-name where the item is found.
    int: The number of occurences with the added random number.
    DataFrame: The converted dictionary.

    Requirements:
    - pandas
    - random

    Example:
    >>> dict = {'A': ['apple', 'banana'], 'B': ['orange', 'apple']}
    >>> task_func(dict, 'apple', seed=12)
    ([(0, 'A'), (1, 'B')], 9,         A       B
    0   apple  orange
    1  banana   apple)
    
    >>> dict = {'A': ['a', 'b', 'e'], 'B': ['c', 'd', 'd'], '2': ['asdf', 'ddd', 'aaaa'], '12': ['e', 'e', 'd']}
    >>> task_func(dict, 'e', seed=2)
    ([(2, 'A'), (0, '12'), (1, '12')], 3,    A  B     2 12
    0  a  c  asdf  e
    1  b  d   ddd  e
    2  e  d  aaaa  d)
    """

instruct prompt

Converts a dictionary to a pandas DataFrame and find the locations of a particular item in the resulting DataFrame. Counts the number of occurences and adds a random integer x, where 0 <=x < 10, to it. >>> dict = {'A': ['a', 'b', 'e'], 'B': ['c', 'd', 'd'], '2': ['asdf', 'ddd', 'aaaa'], '12': ['e', 'e', 'd']} >>> task_func(dict, 'e', seed=2) ([(2, 'A'), (0, '12'), (1, '12')], 3,    A  B     2 12 0  a  c  asdf  e 1  b  d   ddd  e 2  e  d  aaaa  d)
The function should output with:
    list: A list of tuples. Each tuple contains the row-index and column-name where the item is found.
    int: The number of occurences with the added random number.
    DataFrame: The converted dictionary.
You should write self-contained code starting with:

Code

import pandas as pd
import random
def task_func(dictionary, item, seed):

code prompt

Code

import pandas as pd
import random
def task_func(dictionary, item, seed):

entry point

task_func

libs

  • 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