benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 02b9d279-2af2-5f73-a2f7-729885c6f24b

Problem

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

complete prompt

import pandas as pd
import time


def task_func(df, letter):
    """
    The function filters rows in a dict of list in which the values of the 'Word' column begin with a specified letter.
    It first convert the dict to Datafrome, then calculates the length of the words in the filtered column and returns
    a dictionary of word lengths and their respective counts.

    Parameters:
    df (dict of list): A dictionary where the key 'Word' maps to a list of strings.
    letter (str): The letter to filter the 'Word' column by. 

    Returns:
    dict: A dictionary of word lengths and their counts.
    
    Requirements:
    - pandas
    - time

    Example:
    >>> df = {'Word': ['apple', 'banana', 'cherry', 'date', 'fig', 'grape', 'kiwi']}
    >>> task_func(df, 'a')
    {5: 1}
    """

instruct prompt

The function filters rows in a dict of list in which the values of the 'Word' column begin with a specified letter. It first convert the dict to Datafrome, then calculates the length of the words in the filtered column and returns a dictionary of word lengths and their respective counts.
The function should output with:
    dict: A dictionary of word lengths and their counts.
You should write self-contained code starting with:

Code

import pandas as pd
import time
def task_func(df, letter):

code prompt

Code

import pandas as pd
import time
def task_func(df, letter):

entry point

task_func

libs

  • pandas
  • time

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