benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 0e4523ac-6618-57a2-a0eb-a60faaa69cf3

Problem

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

complete prompt

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt


def task_func(dataframe):
    """
    Calculate the correlation matrix of a DataFrame and plot a scatter plot for the pair of columns with the highest absolute correlation.

    Parameters:
    - dataframe (pd.DataFrame): The DataFrame containing numeric columns for correlation calculation.

    Returns:
    - ax (plt.Axes): The scatter plot of the pair of columns with the highest absolute correlation.

    Requirements:
    - pandas
    - numpy
    - matplotlib

    Exception Handling:
    - Raises ValueError if the input DataFrame is empty.
    - Raises TypeError if any column in the DataFrame is non-numeric.
    - Raises ValueError if the DataFrame has fewer than two columns.

    Example:
    >>> df = pd.DataFrame({
    ...     'A': np.random.rand(100),
    ...     'B': np.random.rand(100),
    ...     'C': np.random.rand(100)
    ... })
    >>> ax = task_func(df)
    >>> print(ax)
    Axes(0.125,0.11;0.775x0.77)
    """

instruct prompt

Calculate the correlation matrix of a DataFrame and plot a scatter plot for the pair of columns with the highest absolute correlation. Exception Handling: - Raises ValueError if the input DataFrame is empty. - Raises TypeError if any column in the DataFrame is non-numeric. - Raises ValueError if the DataFrame has fewer than two columns.
The function should output with:
    ax (plt.Axes): The scatter plot of the pair of columns with the highest absolute correlation.
You should write self-contained code starting with:

Code

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
def task_func(dataframe):

code prompt

Code

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
def task_func(dataframe):

entry point

task_func

libs

  • pandas
  • numpy
  • matplotlib

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