benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 22951ecf-9652-56bc-b5c5-e04916ddc8b4

Problem

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

complete prompt

from random import shuffle
import pandas as pd
import numpy as np

# Constants



def task_func(l, n_groups = 5):
    """
    Given a list `l`, this function shuffles the list, constructs a dataframe using the shuffled list,
    and then for each row in the dataframe, moves the first n_groups elements to the end of the same row.

    Parameters:
    - l (list): A list of elements.
    - n_groups (int): number of groups. Default value is 5.

    Returns:
    - DataFrame: A modified DataFrame constructed from the shuffled list.

    Requirements:
    - pandas
    - numpy
    - random

    Example:
    >>> df = task_func(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'])
    >>> df.shape == (5, 10)
    True
    >>> set(df.iloc[0]) == set(['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'])
    True
    """

instruct prompt

Given a list `l`, this function shuffles the list, constructs a dataframe using the shuffled list, and then for each row in the dataframe, moves the first n_groups elements to the end of the same row.
The function should output with:
    DataFrame: A modified DataFrame constructed from the shuffled list.
You should write self-contained code starting with:

Code

from random import shuffle
import pandas as pd
import numpy as np
# Constants
def task_func(l, n_groups = 5):

code prompt

Code

from random import shuffle
import pandas as pd
import numpy as np
# Constants
def task_func(l, n_groups = 5):

entry point

task_func

libs

  • 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