benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 42e6cc02-317f-51c5-bdf0-842ca9f4a5f9

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(file_name: str) -> pd.DataFrame:
    """Normalize data in a csv file using MinMaxScaler from sklearn.
    Only numeric columns are normalized. Columns with other dtypes are left as
    they are.
    
    Parameters:
    file_name (str): The name of the csv file.
    
    Returns:
    DataFrame: A pandas DataFrame with normalized data.

    Raises:
    ValueError: If input does not have numeric columns.

    Requirements:
    - pandas
    - sklearn.preprocessing.MinMaxScaler
    
    Example:
    >>> normalized_data = task_func("sample.csv")
    >>> print(normalized_data.head())
    Name	Age	Salary
    0	Alex Anderson	0.304651	0.122298
    1	Mr. Leslie Casey	0.28140	0.598905
    2	Anthony George	0.996744	0.216552
    3	Brian Washington	0.126279	0.459948
    4	Elias Lawrence	0.337239	0.124185
    """

instruct prompt

Normalize data in a csv file using MinMaxScaler from sklearn. Only numeric columns are normalized. Columns with other dtypes are left as they are.
The function should raise the exception for: ValueError: If input does not have numeric columns.
The function should output with:
    DataFrame: A pandas DataFrame with normalized data.
You should write self-contained code starting with:

Code

import pandas as pd
from sklearn.preprocessing import MinMaxScaler
def task_func(file_name: str) -> pd.DataFrame:

code prompt

Code

import pandas as pd
from sklearn.preprocessing import MinMaxScaler
def task_func(file_name: str) -> pd.DataFrame:

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