benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf 369983a8-1ef4-53f4-bd3d-c17fb87bb5c8
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import numpy as np
import pandas as pd
def task_func(rows=5, cols=5):
"""
Generates a DataFrame with random numerical data and visualizes this data in a stacked bar chart for
specified categories.
Parameters:
rows (int, optional): Number of rows for the DataFrame. Defaults to 5.
cols (int, optional): Number of columns for the DataFrame, corresponding to the number of categories.
Defaults to 5, with a maximum of 5 categories ("A", "B", "C", "D", "E").
Returns:
matplotlib.axes._axes.Axes: The Axes object displaying the stacked bar chart.
Requirements:
- numpy
- pandas
Raises:
ValueError: If the number of columns exceeds the number of available categories.
Example:
>>> import matplotlib
>>> ax = task_func(3, 3) # Generates a 3x3 DataFrame and plots it
>>> isinstance(ax, matplotlib.axes.Axes)
True
"""
instruct prompt
Generates a DataFrame with random numerical data and visualizes this data in a stacked bar chart for specified categories.
The function should raise the exception for: ValueError: If the number of columns exceeds the number of available categories.
The function should output with:
matplotlib.axes._axes.Axes: The Axes object displaying the stacked bar chart.
You should write self-contained code starting with:
Code
import numpy as np
import pandas as pd
def task_func(rows=5, cols=5):
code prompt
Code
import numpy as np
import pandas as pd
def task_func(rows=5, cols=5):
entry point
task_func
libs
- pandas
- numpy
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