benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 7b827b5f-6c4b-540a-837a-1abec52e24d8

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
from sklearn.preprocessing import StandardScaler

# Constants
N_DATA_POINTS = 5000
MIN_VALUE = 0.0
MAX_VALUE = 10.0

def task_func(n_data_points=5000, min_value=0.0, max_value=10.0):
    """
    Generate a random dataset of floating point numbers, truncate each value to 3 decimal places and normalize the data using standard scaling (mean = 0, std = 1).
    
    Parameters:
    n_data_points (int): Number of data points to generate. Default is 5000.
    min_value (float): Minimum value range for data points. Default is 0.0.
    max_value (float): Maximum value range for data points. Default is 10.0.
    
    Returns:
    DataFrame: A pandas DataFrame with the normalized data.
    
    Raises:
    If max_value is less than min_value, a ValueError is raised.
    
    Note:
    - The function use "Normalized Value" for the column name in the DataFrame that being returned.

    Requirements:
    - pandas
    - random
    - sklearn.preprocessing.StandardScaler

    Example:
    >>> random.seed(0)
    >>> normalized_data = task_func(5000, 5, 5)
    >>> print(normalized_data['Normalized Value'][0])
    0.0
    """

instruct prompt

Generate a random dataset of floating point numbers, truncate each value to 3 decimal places and normalize the data using standard scaling (mean = 0, std = 1).
Note that: The function use "Normalized Value" for the column name in the DataFrame that being returned.
The function should raise the exception for: If max_value is less than min_value, a ValueError is raised.
The function should output with:
    DataFrame: A pandas DataFrame with the normalized data.
You should write self-contained code starting with:

Code

import pandas as pd
import random
from sklearn.preprocessing import StandardScaler
# Constants
N_DATA_POINTS = 5000
MIN_VALUE = 0.0
MAX_VALUE = 10.0
def task_func(n_data_points=5000, min_value=0.0, max_value=10.0):

code prompt

Code

import pandas as pd
import random
from sklearn.preprocessing import StandardScaler
# Constants
N_DATA_POINTS = 5000
MIN_VALUE = 0.0
MAX_VALUE = 10.0
def task_func(n_data_points=5000, min_value=0.0, max_value=10.0):

entry point

task_func

libs

  • pandas
  • random
  • sklearn

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