benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf a2baeee3-1719-5a2a-97ec-f1fc836776f1

Problem

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

complete prompt

import pandas as pd
import random
import re

def task_func(person_names, email_domains, num_records=5):
    """
    Generate a DataFrame with a specified number of records containing personal names and emails. 
    The emails are cleaned by replacing all occurrences of "@" with "[at]".
    
    Parameters:
    - person_names (list of str): A list of person names to use in the records.
    - email_domains (list of str): A list of email domains to use in the records.
    - num_records (int, optional): The number of records to generate. Default is 5.
    
    Returns:
    - DataFrame: A pandas DataFrame with columns 'Name' and 'Email' containing the person names and cleaned emails.
    
    Requirements:
    - pandas for DataFrame manipulation
    - random for random selection
    - re for regular expression operations
    
    Raises:
    - ValueError: If the number of names provided is less than the number of records requested or if no email domains are provided.
    
    Example:
    >>> random.seed(0)  # Initialize random seed
    >>> task_func(['John Doe', 'Jane Smith'], ['gmail.com', 'yahoo.com'], 2)
             Name              Email
    0  Jane Smith  jane[at]gmail.com
    1    John Doe  john[at]yahoo.com
    >>> task_func(['Alice'], ['outlook.com'], 1)
        Name                 Email
    0  Alice  alice[at]outlook.com
    """

instruct prompt

Generate a DataFrame with a specified number of records containing personal names and emails. The emails are cleaned by replacing all occurrences of "@" with "[at]".
The function should raise the exception for: ValueError: If the number of names provided is less than the number of records requested or if no email domains are provided.
The function should output with:
    DataFrame: A pandas DataFrame with columns 'Name' and 'Email' containing the person names and cleaned emails.
You should write self-contained code starting with:

Code

import pandas as pd
import random
import re
def task_func(person_names, email_domains, num_records=5):

code prompt

Code

import pandas as pd
import random
import re
def task_func(person_names, email_domains, num_records=5):

entry point

task_func

libs

  • pandas
  • random
  • 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