benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 19a4b39a-ab44-58c6-ab88-903786d02b1d

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, seed=None):
    """
    Generate a DataFrame with random values within a specified range.
    
    This function creates a matrix of given dimensions filled with random values between 0 and 1 and returns it as a Pandas DataFrame. Users have the option to set a random seed for reproducible results.
    
    Parameters:
    - rows (int): The number of rows for the matrix.
    - columns (int): The number of columns for the matrix.
    - seed (int, optional): The seed for the random number generator. Default is None.
    
    Returns:
    - DataFrame: A Pandas DataFrame containing the generated random values.
    
    Requirements:
    - numpy
    - pandas
    
    Examples:
    >>> df = task_func(3, 2, seed=42)
    >>> print(df.shape)
    (3, 2)
    >>> df = task_func(1, 1, seed=24)
    >>> print(df.shape)
    (1, 1)
    """

instruct prompt

Generate a DataFrame with random values within a specified range. This function creates a matrix of given dimensions filled with random values between 0 and 1 and returns it as a Pandas DataFrame. Users have the option to set a random seed for reproducible results.
The function should output with:
    DataFrame: A Pandas DataFrame containing the generated random values.
You should write self-contained code starting with:

Code

import numpy as np
import pandas as pd
def task_func(rows, columns, seed=None):

code prompt

Code

import numpy as np
import pandas as pd
def task_func(rows, columns, seed=None):

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