benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 663a856a-8e51-5ffc-a1ea-b4237d80a6d7

Problem

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

complete prompt

import pandas as pd
from sklearn.preprocessing import MinMaxScaler

# Updated function to handle empty input list
def task_func(d):
    """
    Scale all values with the keys "x," "y" and "z" from a list of dictionaries "d" with MinMaxScaler.

    Parameters:
    d (list): A list of dictionaries.

    Returns:
    DataFrame: A pandas DataFrame with scaled values.

    Requirements:
    - pandas
    - sklearn.preprocessing.MinMaxScaler

    Examples:
    >>> data = [{'x': 1, 'y': 10, 'z': 5}, {'x': 3, 'y': 15, 'z': 6}, {'x': 2, 'y': 1, 'z': 7}]
    >>> print(task_func(data))
         x         y    z
    0  0.0  0.642857  0.0
    1  1.0  1.000000  0.5
    2  0.5  0.000000  1.0

    >>> data = [{'x': -1, 'y': 0, 'z': 5}, {'x': 3, 'y': -15, 'z': 0}, {'x': 0, 'y': 1, 'z': -7}]
    >>> print(task_func(data))
          x       y         z
    0  0.00  0.9375  1.000000
    1  1.00  0.0000  0.583333
    2  0.25  1.0000  0.000000
    """

instruct prompt

Scale all values with the keys "x," "y" and "z" from a list of dictionaries "d" with MinMaxScaler. >>> data = [{'x': -1, 'y': 0, 'z': 5}, {'x': 3, 'y': -15, 'z': 0}, {'x': 0, 'y': 1, 'z': -7}] >>> print(task_func(data)) x       y         z 0  0.00  0.9375  1.000000 1  1.00  0.0000  0.583333 2  0.25  1.0000  0.000000
The function should output with:
    DataFrame: A pandas DataFrame with scaled values.
You should write self-contained code starting with:

Code

import pandas as pd
from sklearn.preprocessing import MinMaxScaler
# Updated function to handle empty input list
def task_func(d):

code prompt

Code

import pandas as pd
from sklearn.preprocessing import MinMaxScaler
# Updated function to handle empty input list
def task_func(d):

entry point

task_func

libs

  • pandas
  • 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