benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf e4cd1819-b629-52f5-858d-cd06a6ca16a1

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(data, column):
    """
    Draw and return a bar chart that shows the distribution of categories in a specific column of a dictionary.
    
    Note:
    The categories are defined by the constant CATEGORIES, 
    which is a list containing ['A', 'B', 'C', 'D', 'E']. If some categories are missing in the DataFrame, 
    they will be included in the plot with a count of zero.
    The x label of the plot is set to 'Category', the y label is set to 'Count', and the title is set to 'Distribution of {column}'.
    
    Parameters:
    - data (dict): A dictionary where the keys are the column names and the values are the column values.
    - column (str): The name of the column in the DataFrame that contains the categories.
    
    Returns:
    - matplotlib.axes._axes.Axes: The Axes object for the generated plot.
    
    Requirements:
    - pandas
    - numpy
    - matplotlib.pyplot
    
    Example:
    >>> data = {'Category': ['A', 'B', 'B', 'C', 'A', 'D', 'E', 'E', 'D']}
    >>> ax = task_func(data, 'Category')    
    >>> data = {'Type': ['A', 'A', 'C', 'E', 'D', 'E', 'D']}
    >>> ax = task_func(data, 'Type')
    """

instruct prompt

Draw and return a bar chart that shows the distribution of categories in a specific column of a dictionary.
Note that: The categories are defined by the constant CATEGORIES, which is a list containing ['A', 'B', 'C', 'D', 'E']. If some categories are missing in the DataFrame, they will be included in the plot with a count of zero. The x label of the plot is set to 'Category', the y label is set to 'Count', and the title is set to 'Distribution of {column}'.
The function should output with:
    matplotlib.axes._axes.Axes: The Axes object for the generated plot.
You should write self-contained code starting with:

Code

import pandas as pd
import matplotlib.pyplot as plt
def task_func(data, column):

code prompt

Code

import pandas as pd
import matplotlib.pyplot as plt
def task_func(data, column):

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