benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf cd0ce3dc-0e23-5cb0-be0c-8235c8d565a2

Problem

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

complete prompt

import re
import pandas as pd

def task_func(df: pd.DataFrame) -> int:
    """
    Count the total number of brackets (i.e., '(', ')', '{', '}', '[', ']') in
    a pandas DataFrame.

    Parameters:
    df (pandas.DataFrame): The DataFrame to process.

    Returns:
    int: The total number of brackets.

    Raises:
    TypeError: If input is not a DataFrame

    Requirements:
    - re
    - pandas

    Note:
    The function uses a specific pattern '[(){}[\]]' to identify brackets.

    Example:
    >>> df = pd.DataFrame({'A': ['(a)', 'b', 'c'], 'B': ['d', 'e', '(f)']})
    >>> task_func(df)
    4

    >>> df = pd.DataFrame({'Test': ['(a)', 'b', '[[[[))c']})
    >>> task_func(df)
    8
    """

instruct prompt

Count the total number of brackets (i.e., '(', ')', '{', '}', '[', ']') in a pandas DataFrame. >>> df = pd.DataFrame({'Test': ['(a)', 'b', '[[[[))c']}) >>> task_func(df) 8
Note that: The function uses a specific pattern '[(){}[\]]' to identify brackets.
The function should raise the exception for: TypeError: If input is not a DataFrame
The function should output with:
    int: The total number of brackets.
You should write self-contained code starting with:

Code

import re
import pandas as pd
def task_func(df: pd.DataFrame) -> int:

code prompt

Code

import re
import pandas as pd
def task_func(df: pd.DataFrame) -> int:

entry point

task_func

libs

  • pandas
  • re

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