benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 444d45eb-e6dd-5f5d-a0ac-59b205d68454

Problem

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

complete prompt

from sklearn.preprocessing import MinMaxScaler
import matplotlib.pyplot as plt


def task_func(df):
    """
    Normalize numeric columns in a DataFrame and draw a box plot for each column. Missing values are replaced by column's average.

    Parameters:
    df (DataFrame): The pandas DataFrame.

    Returns:
    DataFrame: A pandas DataFrame after normalization.
    Axes: A matplotlib Axes displaying a box plot for each column.

    Requirements:
    - pandas
    - numpy
    - sklearn.preprocessing.MinMaxScaler
    - matplotlib.pyplot

    Example:
    >>> import pandas as pd
    >>> import numpy as np
    >>> df = pd.DataFrame([[1,2,3],[4,5,6],[7.0,np.nan,9.0]], columns=["c1","c2","c3"])
    >>> df, ax = task_func(df)
    >>> print(df)
        c1   c2   c3
    0  0.0  0.0  0.0
    1  0.5  1.0  0.5
    2  1.0  0.5  1.0
    """

instruct prompt

Normalize numeric columns in a DataFrame and draw a box plot for each column. Missing values are replaced by column's average.
The function should output with:
    DataFrame: A pandas DataFrame after normalization.
    Axes: A matplotlib Axes displaying a box plot for each column.
You should write self-contained code starting with:

Code

from sklearn.preprocessing import MinMaxScaler
import matplotlib.pyplot as plt
def task_func(df):

code prompt

Code

from sklearn.preprocessing import MinMaxScaler
import matplotlib.pyplot as plt
def task_func(df):

entry point

task_func

libs

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