benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 18b8b9d2-05c7-5f2a-aef4-7b2aa262b07f

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(myList):
    """
    Count the frequency of each word in a list and return a DataFrame of words and their number.

    Parameters:
    myList (list): List of strings. Each string is considered a word regardless of its content,
                                    however the function is case insensitive, and it removes
                                    leading and trailing whitespaces. If empty, function returns
                                    a DataFrame with a Count column that is otherwise empty.

    Returns:
    DataFrame: A pandas DataFrame with words and their counts.

    Requirements:
    - collections.Counter
    - pandas

    Example:
    >>> myList = ['apple', 'banana', 'apple', 'cherry', 'banana', 'banana']
    >>> task_func(myList)
            Count
    apple       2
    banana      3
    cherry      1
    """

instruct prompt

Count the frequency of each word in a list and return a DataFrame of words and their number.
The function should output with:
    DataFrame: A pandas DataFrame with words and their counts.
You should write self-contained code starting with:

Code

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

code prompt

Code

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

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