benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 23435700-b6af-50ad-a47d-eddf87c451d8

Problem

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

complete prompt

import pandas as pd
import re

# Function to replace acronyms in DataFrame
def task_func(data, mapping):
    """
    Replace all acronyms in a DataFrame with their full words according to a provided dictionary.
    
    Requirements:
    - pandas
    - re

    Parameters:
    - data (dict): A dictionary where keys are column names and values are lists of strings.
    - mapping (dict): A dictionary where keys are acronyms and values are the full words.
    
    Returns:
    - pd.DataFrame: A DataFrame where all acronyms in string cells have been replaced with their full words.
    
    Examples:
    >>> data = {'text': ['NASA is great', 'I live in the USA']}
    >>> mapping = {'NASA': 'National Aeronautics and Space Administration', 'USA': 'United States of America'}
    >>> print(task_func(data, mapping))
                                                    text
    0  National Aeronautics and Space Administration ...
    1             I live in the United States of America
    """

instruct prompt

Replace all acronyms in a DataFrame with their full words according to a provided dictionary.
The function should output with:
    pd.DataFrame: A DataFrame where all acronyms in string cells have been replaced with their full words.
You should write self-contained code starting with:

Code

import pandas as pd
import re
# Function to replace acronyms in DataFrame
def task_func(data, mapping):

code prompt

Code

import pandas as pd
import re
# Function to replace acronyms in DataFrame
def task_func(data, mapping):

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