benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 988d644d-56f2-5da1-aeab-43e61c69574f

Problem

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

complete prompt

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm


def task_func(df, column, bins=30, density=True, alpha=0.6, color="g", seed=None):
    """
    Plots a histogram for a specified column of a pandas DataFrame and overlays
    it with a fitted normal distribution curve.

    Parameters:
    - df (pandas.DataFrame): The input DataFrame.
    - column (str): The column name for which the histogram is plotted.
    - bins (int, optional): Number of bins for the histogram. Defaults to 30.
    - density (bool, optional): If True, the histogram is normalized to form a
                                probability density. Defaults to True.
    - alpha (float, optional): Transparency level for the histogram bars.
                               Defaults to 0.6.
    - color (str, optional): Color of the histogram bars. Defaults to 'g'.
    - seed (int, optional): Seed for the random number generator.
                            Defaults to None (not set).

    Returns:
    - matplotlib.axes._axes.Axes: The matplotlib Axes object with the plot.

    Requirements:
    - numpy
    - matplotlib
    - scipy

    Example:
    >>> np.random.seed(0)
    >>> df = pd.DataFrame({'A': np.random.normal(0, 1, 1000)})
    >>> ax = task_func(df, 'A')
    >>> ax.get_title()
    "Normal Fit for 'A'"
    """

instruct prompt

Plots a histogram for a specified column of a pandas DataFrame and overlays it with a fitted normal distribution curve.
The function should output with:
    matplotlib.axes._axes.Axes: The matplotlib Axes object with the plot.
You should write self-contained code starting with:

Code

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
def task_func(df, column, bins=30, density=True, alpha=0.6, color="g", seed=None):

code prompt

Code

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
def task_func(df, column, bins=30, density=True, alpha=0.6, color="g", seed=None):

entry point

task_func

libs

  • 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