benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf e18765a2-9096-50df-9dfb-7afc7f134ebc
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):
"""
Draws a pie chart of the status distribution from a pandas DataFrame with a 'Status' column and returns the plot object.
The 'Status' column in the DataFrame is expected to contain categorical data with possible values like
'Pending', 'In Progress', 'Completed', 'Cancelled'.
Parameters:
df (DataFrame): A pandas DataFrame with 'Status' column containing categorical data.
Returns:
matplotlib.axes.Axes: The Axes object with the pie chart.
Raises:
ValueError: If 'df' is not a pandas DataFrame or does not contain the 'Status' column.
Requirements:
- pandas
- random
- matplotlib.pyplot
Example:
>>> df = pd.DataFrame({'Status': ['Pending', 'Completed', 'In Progress', 'Cancelled', 'Completed', 'Pending']})
>>> ax = task_func(df)
>>> ax.get_title() # Should return 'Status Distribution'
'Status Distribution'
"""
instruct prompt
Draws a pie chart of the status distribution from a pandas DataFrame with a 'Status' column and returns the plot object. The 'Status' column in the DataFrame is expected to contain categorical data with possible values like 'Pending', 'In Progress', 'Completed', 'Cancelled'.
The function should raise the exception for: ValueError: If 'df' is not a pandas DataFrame or does not contain the 'Status' column.
The function should output with:
matplotlib.axes.Axes: The Axes object with the pie 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
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
initial import