benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 41e4540d-8f24-5460-994c-b7b67fa68d87

Problem

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

complete prompt

import pandas as pd
import matplotlib.pyplot as plt

def task_func(df, bins=20):
    """
    Draw a histogram of the last column of the DataFrame and return the plot.

    Parameters:
    - df (DataFrame): The input DataFrame, which must contain at least one column.
    - bins (int, optional): Number of bins for the histogram. Defaults to 20.

    Returns:
    - Axes: A Matplotlib Axes object representing the histogram of the last column. The histogram includes:
      - Title: 'Histogram of ' followed by the name of the last column.
      - X-axis label: 'Value'
      - Y-axis label: 'Frequency'

    Raises:
    - ValueError: If the input is not a DataFrame, or if the DataFrame is empty.

    Requirements:
    - pandas
    - matplotlib.pyplot

    Example:
    >>> df = pd.DataFrame(np.random.randint(0, 100, size=(100, 4)), columns=list('ABCD'))
    >>> ax = task_func(df)
    >>> plt.show()
    """

instruct prompt

Draw a histogram of the last column of the DataFrame and return the plot.
The function should raise the exception for: ValueError: If the input is not a DataFrame, or if the DataFrame is empty.
The function should output with:
    Axes: A Matplotlib Axes object representing the histogram of the last column. The histogram includes:
    Title: 'Histogram of ' followed by the name of the last column.
    X-axis label: 'Value'
    Y-axis label: 'Frequency'
You should write self-contained code starting with:

Code

import pandas as pd
import matplotlib.pyplot as plt
def task_func(df, bins=20):

code prompt

Code

import pandas as pd
import matplotlib.pyplot as plt
def task_func(df, bins=20):

entry point

task_func

libs

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