benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf b7c00403-bab1-5069-9034-082f0835e234

Problem

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

complete prompt

import pandas as pd
import string

def task_func(word):
    """
    Creates a Pandas DataFrame from a single word, where each row contains a letter from the word 
    and its 1-based position in the alphabet.

    Requirements:
    - pandas
    - string
    
    Parameters:
    - word (str): The word to create the DataFrame from. The word should be in lowercase and consist of alphabetic characters only.
    
    Returns:
    - pandas.DataFrame: A DataFrame with two columns: 'Letter' and 'Position', 
      where 'Position' is the letter's position in the English alphabet.
    
    Examples:
    >>> task_func('abc')
      Letter  Position
    0      a         1
    1      b         2
    2      c         3

    >>> task_func('zoo')
      Letter  Position
    0      z        26
    1      o        15
    2      o        15
    
    Raises:
    - ValueError: If the input word is not in lowercase or contains non-alphabetic characters.
    """

instruct prompt

Creates a Pandas DataFrame from a single word, where each row contains a letter from the word and its 1-based position in the alphabet. >>> task_func('zoo') Letter  Position 0      z        26 1      o        15 2      o        15
The function should raise the exception for: ValueError: If the input word is not in lowercase or contains non-alphabetic characters.
The function should output with:
    pandas.DataFrame: A DataFrame with two columns: 'Letter' and 'Position',
    where 'Position' is the letter's position in the English alphabet.
You should write self-contained code starting with:

Code

import pandas as pd
import string
def task_func(word):

code prompt

Code

import pandas as pd
import string
def task_func(word):

entry point

task_func

libs

  • pandas
  • string

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