benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 79a4037b-db59-5cbf-89c0-a10e27b1fed9

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(car_dict):
    """
    With a dictionary of cars as keys and their colors as values, create a DataFrame and visualize the distribution of vehicle colors in a bar chart.
    - The columns of the dataframe should be 'Car' and 'Color'.
    - The plot title should be 'Distribution of Vehicle Colors'.

    Parameters:
    car_dict (dict): The dictionary with car brands as keys and their colors as values.

    Returns:
    tuple: A tuple containing:
        - DataFrame: A pandas DataFrame with car brands and their colors.
        - Axes: The Axes object of the bar chart visualizing the distribution of vehicle colors.

    Requirements:
    - pandas
    - matplotlib

    Example:
    >>> car_dict = {'Ford': 'Red', 'Toyota': 'Blue', 'Mercedes': 'Black', 'Tesla': 'White', 'BMW': 'Silver'}
    >>> df, ax = task_func(car_dict)
    >>> print(df)
            Car   Color
    0      Ford     Red
    1    Toyota    Blue
    2  Mercedes   Black
    3     Tesla   White
    4       BMW  Silver
    """

instruct prompt

With a dictionary of cars as keys and their colors as values, create a DataFrame and visualize the distribution of vehicle colors in a bar chart. - The columns of the dataframe should be 'Car' and 'Color'. - The plot title should be 'Distribution of Vehicle Colors'.
The function should output with:
    tuple: A tuple containing:
    DataFrame: A pandas DataFrame with car brands and their colors.
    Axes: The Axes object of the bar chart visualizing the distribution of vehicle colors.
You should write self-contained code starting with:

Code

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

code prompt

Code

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

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