benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf b0042fd9-e19b-55b8-ad75-c523106d8342

Problem

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

complete prompt

from collections import Counter
import pandas as pd


def task_func(list_of_menuitems):
    """
    Given a nested list of menu items, this function flattens the list and returns a Pandas DataFrame
    detailing the count of each individual menu item with index name 'MenuItem'.

    Parameters:
        list_of_menuitems (list): A nested list of menu items.

    Returns:
        DataFrame: A pandas DataFrame with menu items as indices and a 'Count' column showing the count of each menu item.

    Requirements:
        - collections
        - pandas

    Example:
        >>> result = task_func([['Pizza', 'Burger'], ['Pizza', 'Coke'], ['Pasta', 'Coke']])
        >>> result.loc['Pizza', 'Count']
        2
        >>> result.loc['Coke', 'Count']
        2
    """

instruct prompt

Given a nested list of menu items, this function flattens the list and returns a Pandas DataFrame detailing the count of each individual menu item with index name 'MenuItem'.
The function should output with:
    DataFrame: A pandas DataFrame with menu items as indices and a 'Count' column showing the count of each menu item.
You should write self-contained code starting with:

Code

from collections import Counter
import pandas as pd
def task_func(list_of_menuitems):

code prompt

Code

from collections import Counter
import pandas as pd
def task_func(list_of_menuitems):

entry point

task_func

libs

  • pandas
  • collections

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