benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 88128b25-7465-56ea-9965-f84e628b353f

Problem

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

complete prompt

from sklearn.preprocessing import StandardScaler
import seaborn as sns
import matplotlib.pyplot as plt


def task_func(df):
    """
    Standardize numeric columns in a DataFrame and return the heatmap of the correlation matrix. Missing values are replaced by the column's average.

    Parameters:
    - df (pandas.DataFrame): The pandas DataFrame to be standardized.

    Returns:
    - DataFrame: The pandas DataFrame after standardization.
    - Axes: A heatmap of the correlation matrix.

    Requirements:
    - sklearn.preprocessing.StandardScaler
    - seaborn
    - 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"])
    >>> standardized_df, heatmap = task_func(df)
    >>> print(standardized_df)
             c1        c2        c3
    0 -1.224745 -1.224745 -1.224745
    1  0.000000  1.224745  0.000000
    2  1.224745  0.000000  1.224745
    """

instruct prompt

Standardize numeric columns in a DataFrame and return the heatmap of the correlation matrix. Missing values are replaced by the column's average.
The function should output with:
    DataFrame: The pandas DataFrame after standardization.
    Axes: A heatmap of the correlation matrix.
You should write self-contained code starting with:

Code

from sklearn.preprocessing import StandardScaler
import seaborn as sns
import matplotlib.pyplot as plt
def task_func(df):

code prompt

Code

from sklearn.preprocessing import StandardScaler
import seaborn as sns
import matplotlib.pyplot as plt
def task_func(df):

entry point

task_func

libs

  • 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