benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 25d0a8ef-2ee4-52d6-a9c5-490b26bb2da6

Problem

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

complete prompt

import numpy as np
import pandas as pd

def task_func(rows, columns=["A", "B", "C", "D", "E"], seed=0) -> pd.DataFrame:
    """
    Create a Pandas DataFrame with a specified number of rows filled with random
    values in [0, 1) and shuffled columns.
    
    Note:
    - The columns should be unique and sorted in the ascending order.

    Parameters:
    rows (int): The number of rows for the DataFrame. Must not be negative.
    columns (list of str): Column names for the DataFrame.
                           Defaults to ['A', 'B', 'C', 'D', 'E'].
                           If it contains repeated columns, the function deduplicates
                           it in a case and spacing sensitive way. If it is empty,
                           the function returns an empty DataFrame.
    seed (int): The random seed for reproducibility.
    
    Returns:
    pd.DataFrame: A pandas DataFrame with shuffled columns.

    Requirements:
    - numpy
    - pandas

    Example:
    >>> df = task_func(10)
    >>> df.head(2)
              D         E         A         C         B
    0  0.548814  0.715189  0.602763  0.544883  0.423655
    1  0.645894  0.437587  0.891773  0.963663  0.383442
    """

instruct prompt

Create a Pandas DataFrame with a specified number of rows filled with random values in [0, 1) and shuffled columns.
Note that: The columns should be unique and sorted in the ascending order.
The function should output with:
    pd.DataFrame: A pandas DataFrame with shuffled columns.
You should write self-contained code starting with:

Code

import numpy as np
import pandas as pd
def task_func(rows, columns=["A", "B", "C", "D", "E"], seed=0) -> pd.DataFrame:

code prompt

Code

import numpy as np
import pandas as pd
def task_func(rows, columns=["A", "B", "C", "D", "E"], seed=0) -> pd.DataFrame:

entry point

task_func

libs

  • pandas
  • numpy

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