benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 0020ba4b-aa63-55ff-8a11-6fde4bc76502

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

def task_func(data, columns):
    """
    Normalizes specified columns of a DataFrame using min-max scaling.

    Parameters:
    data (dict): A dictionary where keys are column names and values are lists of values.
    columns (list of str): A list of column names to be normalized.

    Returns:
    pandas.DataFrame: A new DataFrame with the specified columns normalized between 0 and 1.

    Requirements:
    - pandas
    - sklearn.preprocessing

    Constants:
    - A MinMaxScaler object from sklearn.preprocessing is used internally for scaling.

    Example:
    >>> data = {'a': [1, 2, 3], 'b': [4, 5, 6]}
    >>> normalized_df = task_func(data, ['a', 'b'])
    >>> print(normalized_df)
         a    b
    0  0.0  0.0
    1  0.5  0.5
    2  1.0  1.0
    """

instruct prompt

Normalizes specified columns of a DataFrame using min-max scaling. Constants: - A MinMaxScaler object from sklearn.preprocessing is used internally for scaling.
The function should output with:
    pandas.DataFrame: A new DataFrame with the specified columns normalized between 0 and 1.
You should write self-contained code starting with:

Code

import pandas as pd
from sklearn.preprocessing import MinMaxScaler
def task_func(data, columns):

code prompt

Code

import pandas as pd
from sklearn.preprocessing import MinMaxScaler
def task_func(data, columns):

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