benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 4e02abf4-d93f-5b4f-a436-4fc5b8d71d0b

Problem

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

complete prompt

import seaborn as sns
import numpy as np


def task_func(df):
    """
    Generates a pair plot from a numeric DataFrame and calculates its covariance matrix.

    Parameters:
    - df (pandas.DataFrame): A pandas DataFrame with only numeric columns.

    Returns:
    - tuple:
        - covariance_df (pandas.DataFrame): The covariance matrix of the input DataFrame.
        - pair_plot (sns.axisgrid.PairGrid): Pair plot of the input DataFrame.

    Raises:
    - ValueError: If the DataFrame is empty.
    - TypeError: If the DataFrame contains non-numeric data types.

    Requirements:
    - numpy
    - seaborn

    Examples:
    >>> import pandas as pd
    >>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6], 'C': [7, 8, 9]})
    >>> covariance_df, ax = task_func(df)
    >>> type(ax)
    <class 'seaborn.axisgrid.PairGrid'>
    >>> covariance_df
         A    B    C
    A  1.0  1.0  1.0
    B  1.0  1.0  1.0
    C  1.0  1.0  1.0
    """

instruct prompt

Generates a pair plot from a numeric DataFrame and calculates its covariance matrix.
The function should raise the exception for: ValueError: If the DataFrame is empty. TypeError: If the DataFrame contains non-numeric data types.
The function should output with:
    tuple:
    covariance_df (pandas.DataFrame): The covariance matrix of the input DataFrame.
    pair_plot (sns.axisgrid.PairGrid): Pair plot of the input DataFrame.
You should write self-contained code starting with:

Code

import seaborn as sns
import numpy as np
def task_func(df):

code prompt

Code

import seaborn as sns
import numpy as np
def task_func(df):

entry point

task_func

libs

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