benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf bd60391e-3c44-54bd-a3a4-3c4f94474e9b

Problem

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

complete prompt

import pandas as pd
import codecs

def task_func(dataframe: pd.DataFrame) -> pd.DataFrame:
    """
    Decodes all Unicode escape strings in a particular column ("UnicodeString") in a given Pandas DataFrame.

    Parameters:
    dataframe (pd.DataFrame): The pandas DataFrame which must contain the column "UnicodeString".

    Returns:
    pd.DataFrame: The DataFrame with decoded strings in the "UnicodeString" column.

    Raises:
    KeyError: If the column "UnicodeString" does not exist in the DataFrame.
    TypeError: If the input is not a Pandas DataFrame.

    Example:
    >>> df = pd.DataFrame({
    ...     'Name': ['John', 'Anna', 'Peter'],
    ...     'Age': [27, 23, 29],
    ...     'Salary': [50000, 60000, 70000],
    ...     'UnicodeString': ['\u004A\u006F\u0068\u006E', '\u0041\u006E\u006E\u0061', '\u0050\u0065\u0074\u0065\u0072']
    ... })
    >>> task_func(df)
        Name  Age  Salary UnicodeString
    0   John   27   50000          John
    1   Anna   23   60000          Anna
    2  Peter   29   70000         Peter

    Requirements:
    - pandas
    - codecs
    """

instruct prompt

Decodes all Unicode escape strings in a particular column ("UnicodeString") in a given Pandas DataFrame.
The function should raise the exception for: KeyError: If the column "UnicodeString" does not exist in the DataFrame. TypeError: If the input is not a Pandas DataFrame.
The function should output with:
    pd.DataFrame: The DataFrame with decoded strings in the "UnicodeString" column.
You should write self-contained code starting with:

Code

import pandas as pd
import codecs
def task_func(dataframe: pd.DataFrame) -> pd.DataFrame:

code prompt

Code

import pandas as pd
import codecs
def task_func(dataframe: pd.DataFrame) -> pd.DataFrame:

entry point

task_func

libs

  • codecs
  • pandas

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