benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf 7c148ef9-f9a5-5cb1-ab3c-ef067b2f7082
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
import numpy as np
def task_func(num_labels=5, data_range=(0, 1)):
"""
Generate random numeric data across a specified range for a given number of categories and visualize it with
a stacked bar chart.
Parameters:
num_labels (int): Specifies the number of distinct categories or labels to generate data for. Defaults to 5.
data_range (tuple): Defines the lower and upper bounds for the random data values. Defaults to (0, 1).
Returns:
matplotlib.figure.Figure: A Figure object containing the stacked bar chart of the generated data.
Requirements:
- pandas
- matplotlib
- numpy
Example:
>>> fig = task_func()
>>> fig.show() # This will display the figure with default parameters
>>> fig = task_func(num_labels=3, data_range=(1, 10))
>>> fig.show() # This will display the figure with three labels and data range from 1 to 10
"""
instruct prompt
Generate random numeric data across a specified range for a given number of categories and visualize it with a stacked bar chart. >>> fig = task_func(num_labels=3, data_range=(1, 10)) >>> fig.show() # This will display the figure with three labels and data range from 1 to 10
The function should output with:
matplotlib.figure.Figure: A Figure object containing the stacked bar chart of the generated data.
You should write self-contained code starting with:
Code
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
def task_func(num_labels=5, data_range=(0, 1)):
code prompt
Code
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
def task_func(num_labels=5, data_range=(0, 1)):
entry point
task_func
libs
- pandas
- numpy
- 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