benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 1081e435-e5b9-5fd1-acc2-8b138f2220ac

Problem

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

complete prompt

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


def task_func(a, b):
    """
    Calculate the Pearson correlation coefficient of two lists, generate a Pandas DataFrame from these lists, and then draw a scatter plot with a regression line.

    Parameters:
    a (list): A list of numbers.
    b (list): Another list of numbers.

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

    Returns:
    - tuple: Contains two elements:
        - float: The Pearson correlation coefficient.
        - matplotlib.axes.Axes: The Axes object of the plotted scatter plot with a regression line.


    Example:
    >>> correlation, ax = task_func([1, 2, 3, 4, 5], [2, 4, 6, 8, 10])
    >>> isinstance(correlation, float) and isinstance(ax, matplotlib.axes.Axes)
    True
    >>> round(correlation, 1)
    1.0
    """

instruct prompt

Calculate the Pearson correlation coefficient of two lists, generate a Pandas DataFrame from these lists, and then draw a scatter plot with a regression line.
The function should output with:
    tuple: Contains two elements:
    float: The Pearson correlation coefficient.
    matplotlib.axes.Axes: The Axes object of the plotted scatter plot with a regression line.
You should write self-contained code starting with:

Code

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy import stats
def task_func(a, b):

code prompt

Code

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from scipy import stats
def task_func(a, b):

entry point

task_func

libs

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