benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf ecf710ca-70c4-5ed3-952c-781655e7c222

Problem

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

complete prompt

import pandas as pd
import seaborn as sns

def task_func(df, col1, col2):
    """
    Draw a scatter plot with a regression line for two columns from a DataFrame.

    Parameters:
    df (DataFrame): Input DataFrame.
    col1 (str): Name of the first column.
    col2 (str): Name of the second column.

    Returns:
    Axes: A seaborn axes object.

    Requirements:
    - pandas
    - seaborn

    Raises:
    - Raise ValueError if the input df is not a DataFrame, empty, or does not contain the specified columns.
    - Raise TypeError if df use non-numeric data

    Example:
    >>> import matplotlib.pyplot as plt
    >>> df = pd.DataFrame({'X': [1, 2, 3, 4, 5], 'Y': [2, 4, 6, 8, 10]})
    >>> plot = task_func(df, 'X', 'Y')
    >>> len(plot.collections[0].get_offsets().data)
    5
    >>> plt.close()
    """

instruct prompt

Draw a scatter plot with a regression line for two columns from a DataFrame.
The function should raise the exception for: Raise ValueError if the input df is not a DataFrame, empty, or does not contain the specified columns. Raise TypeError if df use non-numeric data
The function should output with:
    Axes: A seaborn axes object.
You should write self-contained code starting with:

Code

import pandas as pd
import seaborn as sns
def task_func(df, col1, col2):

code prompt

Code

import pandas as pd
import seaborn as sns
def task_func(df, col1, col2):

entry point

task_func

libs

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