benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf af6e2f14-876f-5db2-a356-f6e1229499d1

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(input_df):
    """
    Cleans the text in a pandas DataFrame column named 'text' by removing all special characters, punctuation marks, and spaces, then calculates the length of the cleaned text.

    Requirements:
    - re
    - pandas

    Parameters:
    - input_df (pandas.DataFrame): DataFrame with a column 'text' containing strings with alphanumeric and/or special characters.

    Returns:
    - pandas.DataFrame: A DataFrame with two new columns 'clean_text' and 'text_length', where 'clean_text' is the cleaned text and 'text_length' is its length.

    Examples:
    >>> df = pd.DataFrame({'text': ['Special $#! characters   spaces 888323']})
    >>> print(task_func(df))
                          clean_text  text_length
    0  Specialcharactersspaces888323           29
    >>> df = pd.DataFrame({'text': ['Hello, World!']})
    >>> print(task_func(df))
       clean_text  text_length
    0  HelloWorld           10
    """

instruct prompt

Cleans the text in a pandas DataFrame column named 'text' by removing all special characters, punctuation marks, and spaces, then calculates the length of the cleaned text.
The function should output with:
    pandas.DataFrame: A DataFrame with two new columns 'clean_text' and 'text_length', where 'clean_text' is the cleaned text and 'text_length' is its length.
You should write self-contained code starting with:

Code

import re
import pandas as pd
def task_func(input_df):

code prompt

Code

import re
import pandas as pd
def task_func(input_df):

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