benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf 85bb3637-3e15-58c7-8f5c-d57feb727bfd
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
from random import randint
def task_func(num_types=5, integer_range=(0, 100)):
"""
Generate a DataFrame containing random integer values across a specified number of categories,
and visualize these data as a horizontal stacked bar chart.
Parameters:
num_types (int, optional): The number of distinct categories for which data will be generated. Defaults to 5.
integer_range (tuple, optional): The inclusive range from which random integers are drawn. Defaults to (0, 100).
Returns:
tuple: A tuple containing a matplotlib Figure and Axes objects for the generated plot.
Requirements:
- pandas
- matplotlib
- random
Note:
The plot displays categories on the y-axis and their corresponding values on the x-axis, with
data segmented by category.
Example:
>>> fig, ax = task_func(3, (0, 50))
>>> isinstance(fig, plt.Figure)
True
"""
instruct prompt
Generate a DataFrame containing random integer values across a specified number of categories, and visualize these data as a horizontal stacked bar chart.
Note that: The plot displays categories on the y-axis and their corresponding values on the x-axis, with data segmented by category.
The function should output with:
tuple: A tuple containing a matplotlib Figure and Axes objects for the generated plot.
You should write self-contained code starting with:
Code
import pandas as pd
import matplotlib.pyplot as plt
from random import randint
def task_func(num_types=5, integer_range=(0, 100)):
code prompt
Code
import pandas as pd
import matplotlib.pyplot as plt
from random import randint
def task_func(num_types=5, integer_range=(0, 100)):
entry point
task_func
libs
- pandas
- random
- 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