benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 22fed0da-fed1-5db8-8cad-5602792c6226

Problem

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

complete prompt

import pandas as pd
from scipy import stats
import matplotlib.pyplot as plt

def task_func(df):
    """
    Perform a linear regression between "age" and "score" in the DataFrame, excluding rows with duplicate names.
    Plot the regression line and the scatter plot of the data.

    Parameters:
    df (DataFrame): The pandas DataFrame containing the data.

    Returns:
    tuple: A tuple containing the matplotlib.pyplot object and the axes object.

    Raises:
    - The function will raise a ValueError is input df is not a DataFrame.

    Note:
    - The function use "Linear Regression" for the plot title.
    - The function use "Age" and "Score" as the xlabel and ylabel respectively.

    Requirements:
    - pandas
    - scipy.stats
    - matplotlib.pyplot

    Example:
    >>> data = pd.DataFrame([{'Name': 'Alice', 'Age': 20, 'Score': 70}, {'Name': 'Bob', 'Age': 25, 'Score': 75}, {'Name': 'Eve', 'Age': 30, 'Score': 80}])
    >>> plt, ax = task_func(data)
    >>> ax.lines[0].get_xdata()[0]
    20
    """

instruct prompt

Perform a linear regression between "age" and "score" in the DataFrame, excluding rows with duplicate names. Plot the regression line and the scatter plot of the data.
Note that: The function use "Linear Regression" for the plot title. The function use "Age" and "Score" as the xlabel and ylabel respectively.
The function should raise the exception for: The function will raise a ValueError is input df is not a DataFrame.
The function should output with:
    tuple: A tuple containing the matplotlib.pyplot object and the axes object.
You should write self-contained code starting with:

Code

import pandas as pd
from scipy import stats
import matplotlib.pyplot as plt
def task_func(df):

code prompt

Code

import pandas as pd
from scipy import stats
import matplotlib.pyplot as plt
def task_func(df):

entry point

task_func

libs

  • pandas
  • matplotlib
  • scipy

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