benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 953acc58-1fd1-5244-9366-6d97c12de0d5

Problem

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

complete prompt

import pandas as pd
import numpy as np


CATEGORIES = ["Electronics", "Clothing", "Home Decor", "Automotive", "Books"]


def task_func(s1, s2):
    """
    Compares and visualizes the sales data of two stores for predefined categories.
    The function generates a bar plot for categories where both stores have sales exceeding a specified threshold.
    The Euclidean distance between the two series is also computed.
    
    Parameters:
    s1 (pd.Series): Sales data for store 1, indexed by categories.
    s2 (pd.Series): Sales data for store 2, indexed by categories.

    Returns:
    matplotlib.axes.Axes or None: A bar plot for categories where both stores' sales exceed the threshold of 200,
    or None if no such categories exist.
    float: The Euclidean distance between the two series or 0.0 if no categories meet the threshold.

    Requirements:
    - pandas
    - numpy

    Example:
    >>> np.random.seed(seed=32)
    >>> s1 = pd.Series(np.random.randint(100, 500, size=5), index=CATEGORIES)
    >>> s2 = pd.Series(np.random.randint(150, 600, size=5), index=CATEGORIES)
    >>> ax, edit_distance = task_func(s1, s2)
    >>> ax.get_title()
    'Sales Comparison Above Threshold in Categories'
    >>> edit_distance
    387.5590277622236
    """

instruct prompt

Compares and visualizes the sales data of two stores for predefined categories. The function generates a bar plot for categories where both stores have sales exceeding a specified threshold. The Euclidean distance between the two series is also computed.
The function should output with:
    matplotlib.axes.Axes or None: A bar plot for categories where both stores' sales exceed the threshold of 200,
    or None if no such categories exist.
    float: The Euclidean distance between the two series or 0.0 if no categories meet the threshold.
You should write self-contained code starting with:

Code

import pandas as pd
import numpy as np
CATEGORIES = ["Electronics", "Clothing", "Home Decor", "Automotive", "Books"]
def task_func(s1, s2):

code prompt

Code

import pandas as pd
import numpy as np
CATEGORIES = ["Electronics", "Clothing", "Home Decor", "Automotive", "Books"]
def task_func(s1, s2):

entry point

task_func

libs

  • pandas
  • numpy

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