benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf b37c7ac4-1345-5e2b-9b81-ade8f29413bd

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 shuffle

# Constants
POSSIBLE_VALUES = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]


def task_func(list_of_lists):
    """
    Generate a list of pandas DataFrames, each created from a sublist in 'list_of_lists'.
    Each DataFrame has columns named as per the elements of the sublist, and each column
    is filled with randomly shuffled values from 'POSSIBLE_VALUES'.

    Parameters:
    - list_of_lists (list of list): A list where each element is a list of strings
    representing column names for a DataFrame.

    Returns:
    - list of pandas.DataFrame: A list where each element is a DataFrame with columns as specified
    in 'list_of_lists', and each column contains shuffled values from 'POSSIBLE_VALUES'.

    Requirements:
    - pandas
    - random.shuffle

    Note:
    - The length of each DataFrame's columns is equal to the length of 'POSSIBLE_VALUES'.
    - Each column in the DataFrame has the same shuffled order of 'POSSIBLE_VALUES'.

    Example:
    >>> import random
    >>> random.seed(0)
    >>> dfs = task_func([['x', 'y', 'z'], ['a', 'b', 'c']])
    >>> dfs[0].head()
       x  y  z
    0  H  J  H
    1  I  E  A
    2  B  I  J
    3  F  G  D
    4  D  A  C
    """

instruct prompt

Generate a list of pandas DataFrames, each created from a sublist in 'list_of_lists'. Each DataFrame has columns named as per the elements of the sublist, and each column is filled with randomly shuffled values from 'POSSIBLE_VALUES'.
Note that: The length of each DataFrame's columns is equal to the length of 'POSSIBLE_VALUES'. Each column in the DataFrame has the same shuffled order of 'POSSIBLE_VALUES'.
The function should output with:
    list of pandas.DataFrame: A list where each element is a DataFrame with columns as specified
    in 'list_of_lists', and each column contains shuffled values from 'POSSIBLE_VALUES'.
You should write self-contained code starting with:

Code

import pandas as pd
from random import shuffle
# Constants
POSSIBLE_VALUES = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]
def task_func(list_of_lists):

code prompt

Code

import pandas as pd
from random import shuffle
# Constants
POSSIBLE_VALUES = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J"]
def task_func(list_of_lists):

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