benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 45f26b8e-9b91-565d-b76e-9cd3eb21fc80

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns

PRODUCTS = ['Product' + str(i) for i in range(1, 6)]
MONTHS = ['Month' + str(i) for i in range(1, 13)]


def task_func():
    """
    Generate a DataFrame representing monthly sales of products and visualize the total sales.

    The function creates a DataFrame where each row represents a month, each column represents a product,
    and cell values represent sales figures. It then plots the total sales per product across all months
    using both a line plot and a heatmap for visualization.

    Returns:
    - pd.DataFrame: A DataFrame with randomly generated sales figures for each product over 12 months.

    The function also displays:
    - A line plot showing the total sales per product.
    - A heatmap visualizing sales figures across products and months.

    Requirements:
    - pandas
    - numpy
    - matplotlib.pyplot
    - seaborn

    Example:
    >>> df = task_func()
    >>> df.shape
    (12, 5)
    >>> all(df.columns == PRODUCTS)
    True
    >>> all(df.index == MONTHS)
    True
    >>> (df.values >= 100).all() and (df.values <= 1000).all()
    True
    """

instruct prompt

Generate a DataFrame representing monthly sales of products and visualize the total sales. The function creates a DataFrame where each row represents a month, each column represents a product, and cell values represent sales figures. It then plots the total sales per product across all months using both a line plot and a heatmap for visualization. The function also displays: - A line plot showing the total sales per product. - A heatmap visualizing sales figures across products and months.
The function should output with:
    pd.DataFrame: A DataFrame with randomly generated sales figures for each product over 12 months.
You should write self-contained code starting with:

Code

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
PRODUCTS = ['Product' + str(i) for i in range(1, 6)]
MONTHS = ['Month' + str(i) for i in range(1, 13)]
def task_func():

code prompt

Code

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns
PRODUCTS = ['Product' + str(i) for i in range(1, 6)]
MONTHS = ['Month' + str(i) for i in range(1, 13)]
def task_func():

entry point

task_func

libs

  • pandas
  • numpy
  • matplotlib
  • seaborn

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