benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf fe05e07b-c4a7-50bf-8f54-0d85f22262b2

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_groups=5, data_size=5, labels=None):
    """
    Generate random data and visualize it with a stacked bar chart, saving the chart to a file.
    This function facilitates the exploration and sharing of data distribution across multiple categories.

    Parameters:
    num_groups (int): Number of groups for which data is to be generated, defaulting to 5.
    data_size (int): Number of data points for each group, defaulting to 5.
    labels (list of str, optional): Labels for the groups. If None, default labels 'Group1', 'Group2', ...,
    'GroupN' are generated.

    Returns:
    tuple: A tuple containing:
        - matplotlib.figure.Figure: The Figure object containing the stacked bar chart.
        - pandas.DataFrame: The DataFrame with randomly generated data.
        - str: The filename where the plot is saved ('test_plot.png').

    Requirements:
    - pandas
    - matplotlib
    - numpy

    Example:
    >>> np.random.seed(0)
    >>> fig, data, plot_filename = task_func(3, 3, ['A', 'B', 'C'])
    >>> print(data)
              A         B         C
    0  0.548814  0.715189  0.602763
    1  0.544883  0.423655  0.645894
    2  0.437587  0.891773  0.963663
    >>> print(plot_filename)
    test_plot.png
    """

instruct prompt

Generate random data and visualize it with a stacked bar chart, saving the chart to a file. This function facilitates the exploration and sharing of data distribution across multiple categories.
The function should output with:
    tuple: A tuple containing:
    matplotlib.figure.Figure: The Figure object containing the stacked bar chart.
    pandas.DataFrame: The DataFrame with randomly generated data.
    str: The filename where the plot is saved ('test_plot.png').
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_groups=5, data_size=5, labels=None):

code prompt

Code

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
def task_func(num_groups=5, data_size=5, labels=None):

entry point

task_func

libs

  • pandas
  • numpy
  • 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