benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 5af9b939-9de0-5eb3-a295-179176200231

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
import seaborn as sns
from sklearn.preprocessing import MinMaxScaler


def task_func(data: pd.DataFrame) -> (pd.DataFrame, plt.Axes):
    """
    Normalize the data and visualize it using a heatmap.

    This function takes a pandas DataFrame, normalizes the data to a range [0, 1], and then visualizes this
    normalized data using a seaborn heatmap.  The heatmap uses the "YlGnBu" colormap to represent normalized
    values and includes a color bar labeled "Normalized Value" to indicate the range of data values.
    It returns both the normalized data and the heatmap plot.

    Parameters:
    - data (pd.DataFrame): The input data with multiple features in columns.

    Returns:
    - pd.DataFrame: Normalized data.
    - plt.Axes: Heatmap plot of the normalized data.

    Requirements:
    - pandas
    - numpy
    - matplotlib.pyplot
    - seaborn
    
    Example:
    >>> df = pd.DataFrame([[1,1,1], [2,2,2], [3,3,3]], columns=['Feature1', 'Feature2', 'Feature3'])
    >>> normalized_df, _ = task_func(df)
    >>> type(normalized_df)
    <class 'pandas.core.frame.DataFrame'>
    >>> normalized_df['Feature1'].iloc[0]  # Returns a normalized value between 0 and 1
    0.0
    """

instruct prompt

Normalize the data and visualize it using a heatmap. This function takes a pandas DataFrame, normalizes the data to a range [0, 1], and then visualizes this normalized data using a seaborn heatmap.  The heatmap uses the "YlGnBu" colormap to represent normalized values and includes a color bar labeled "Normalized Value" to indicate the range of data values. It returns both the normalized data and the heatmap plot.
The function should output with:
    pd.DataFrame: Normalized data.
    plt.Axes: Heatmap plot of the normalized data.
You should write self-contained code starting with:

Code

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.preprocessing import MinMaxScaler
def task_func(data: pd.DataFrame) -> (pd.DataFrame, plt.Axes):

code prompt

Code

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.preprocessing import MinMaxScaler
def task_func(data: pd.DataFrame) -> (pd.DataFrame, plt.Axes):

entry point

task_func

libs

  • pandas
  • sklearn
  • matplotlib
  • seaborn

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