benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 9b8676c5-29dd-58d6-82b9-686849d1693f

Problem

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

complete prompt

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

def task_func(df):
    """
    Normalize the last column of the DataFrame using MinMaxScaler from sklearn and plot the normalized data.

    Parameters:
    - df (DataFrame): The input DataFrame.
    - bins (int, optional): Number of bins for the histogram. Defaults to 20.

    Returns:
    - DataFrame: A pandas DataFrame where the last column has been normalized.
    - Axes: A Matplotlib Axes object representing the plot of the normalized last column. The plot includes:
      - Title: 'Normalized Data of <column_name>'
      - X-axis label: 'Index'
      - Y-axis label: 'Normalized Value'

    Raises:
    - ValueError: If the input is not a DataFrame or if the DataFrame is empty.

    Requirements:
    - pandas
    - matplotlib.pyplot
    - sklearn

    Example:
    >>> df = pd.DataFrame(np.random.randint(0, 100, size=(100, 4)), columns=list('ABCD'))
    >>> normalized_df, ax = task_func(df)
    >>> plt.show()
    """

instruct prompt

Normalize the last column of the DataFrame using MinMaxScaler from sklearn and plot the normalized data.
The function should raise the exception for: ValueError: If the input is not a DataFrame or if the DataFrame is empty.
The function should output with:
    DataFrame: A pandas DataFrame where the last column has been normalized.
    Axes: A Matplotlib Axes object representing the plot of the normalized last column. The plot includes:
    Title: 'Normalized Data of <column_name>'
    X-axis label: 'Index'
    Y-axis label: 'Normalized Value'
You should write self-contained code starting with:

Code

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

code prompt

Code

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

entry point

task_func

libs

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