benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 7a4ce2be-4df8-5e95-af70-992abee52299

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


# Constants
N_DATA_POINTS = 10000
MIN_VALUE = 0.0
MAX_VALUE = 10.0

def task_func(n_data_points=N_DATA_POINTS):
    '''
    Generate a random set of floating-point numbers, truncate each value to 3 decimal places, and return them in a DataFrame.
    The number of data points to generate can be specified. If zero, returns an empty DataFrame.

    Parameters:
    n_data_points (int): Number of data points to generate. Default is 10000.

    Returns:
    DataFrame: A pandas DataFrame containing one column 'Value' with the generated data. Empty if n_data_points is 0.

    Note:
    - This function use 'Value' for the column name in returned DataFrame 

    Requirements:
    - pandas
    - random

    Example:
    >>> random.seed(0)
    >>> data = task_func(20)
    >>> print(data.shape)
    (20, 1)
    >>> MIN_VALUE <= data.iloc[0]['Value'] <= MAX_VALUE
    True
    '''

instruct prompt

Generate a random set of floating-point numbers, truncate each value to 3 decimal places, and return them in a DataFrame. The number of data points to generate can be specified. If zero, returns an empty DataFrame.
Note that: This function use 'Value' for the column name in returned DataFrame
The function should output with:
    DataFrame: A pandas DataFrame containing one column 'Value' with the generated data. Empty if n_data_points is 0.
You should write self-contained code starting with:

Code

import pandas as pd
import random
# Constants
N_DATA_POINTS = 10000
MIN_VALUE = 0.0
MAX_VALUE = 10.0
def task_func(n_data_points=N_DATA_POINTS):

code prompt

Code

import pandas as pd
import random
# Constants
N_DATA_POINTS = 10000
MIN_VALUE = 0.0
MAX_VALUE = 10.0
def task_func(n_data_points=N_DATA_POINTS):

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