benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 1ef6deef-e208-5a08-8526-4b32c5e71e39

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):
    """
    Draw a bar chart of the counts of each unique value in the 'value' column of a pandas DataFrame and return the Axes object.
    Empty DataFrame will return an empty bar chart.
    
    Parameters:
    df (DataFrame): The pandas DataFrame with columns ['id', 'value'].

    Returns:
    Axes: The matplotlib Axes object of the bar chart.

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

    Note:
    - This function use "Value Distribution" for the plot title.
    - This function use "Value" and "Count" as the xlabel and ylabel respectively.

    Requirements:
    - pandas
    - matplotlib.pyplot

    Example:
    >>> df = pd.DataFrame({'id': [1, 1, 2, 2, 3, 3],'value': ['A', 'B', 'A', 'B', 'A', 'B']})
    >>> ax = task_func(df)
    >>> len(ax.patches)
    2
    >>> plt.close()
    """

instruct prompt

Draw a bar chart of the counts of each unique value in the 'value' column of a pandas DataFrame and return the Axes object. Empty DataFrame will return an empty bar chart.
Note that: This function use "Value Distribution" for the plot title. This function use "Value" and "Count" 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:
    Axes: The matplotlib Axes object of the bar chart.
You should write self-contained code starting with:

Code

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

code prompt

Code

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

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