benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf c2c73429-21ae-5e3a-a3c6-a5cce62a40cf

Problem

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

complete prompt

import numpy as np
import pandas as pd


def task_func(df, letter):
    """
    This function converts an input dictionary into a DataFrame, filters rows where 'Word' column values start with a
    specified letter, calculates the lengths of these words, and returns basic statistics (mean, median, mode) of the
    word lengths.

    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.

    Returns:
    dict: A dictionary of mean, median, and mode of word lengths.
    
    Requirements:
    - pandas
    - numpy

    Example:
    >>> df = {'Word': ['apple', 'banana', 'apricot', 'blueberry', 'cherry', 'avocado']}
    >>> stats = task_func(df, 'a')
    >>> stats['mean'] > 0
    True
    >>> stats['median'] > 0
    True
    """

instruct prompt

This function converts an input dictionary into a DataFrame, filters rows where 'Word' column values start with a specified letter, calculates the lengths of these words, and returns basic statistics (mean, median, mode) of the word lengths.
The function should output with:
    dict: A dictionary of mean, median, and mode of word lengths.
You should write self-contained code starting with:

Code

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

code prompt

Code

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

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