benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 26232fca-ac5b-56aa-8344-919362e2716a

Problem

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

complete prompt

import pandas as pd
import regex as re
import seaborn as sns
import matplotlib.pyplot as plt

COLUMN_NAMES = ["Name", "Email", "Age", "Country"]


def task_func(text):
    """
    Extract data from a text and create a Pandas DataFrame.
    The text contains several lines, each formatted as 'Name: John Doe, Email: john.doe@example.com, Age: 30, Country: USA'.
    Plot the age distribution using seaborn.

    The data is extracted using the regular expression pattern:
    "Name: (.*?), Email: (.*?), Age: (.*?), Country: (.*?)($|\n)"
    and the resulting DataFrame has columns: ['Name', 'Email', 'Age', 'Country']

    Parameters:
    text (str): The text to analyze.

    Returns:
    DataFrame: A pandas DataFrame with extracted data.

    Requirements:
    - pandas
    - regex
    - seaborn
    - matplotlib.pyplot

    Example:
    >>> text = 'Name: John Doe, Email: john.doe@example.com, Age: 30, Country: USA\\nName: Jane Doe, Email: jane.doe@example.com, Age: 25, Country: UK'
    >>> df = task_func(text)
    >>> print(df)
           Name                 Email  Age Country
    0  John Doe  john.doe@example.com   30     USA
    1  Jane Doe  jane.doe@example.com   25      UK
    """

instruct prompt

Extract data from a text and create a Pandas DataFrame. The text contains several lines, each formatted as 'Name: John Doe, Email: john.doe@example.com, Age: 30, Country: USA'. Plot the age distribution using seaborn. The data is extracted using the regular expression pattern: "Name: (.*?), Email: (.*?), Age: (.*?), Country: (.*?)($|\n)" and the resulting DataFrame has columns: ['Name', 'Email', 'Age', 'Country']
The function should output with:
    DataFrame: A pandas DataFrame with extracted data.
You should write self-contained code starting with:

Code

import pandas as pd
import regex as re
import seaborn as sns
import matplotlib.pyplot as plt
COLUMN_NAMES = ["Name", "Email", "Age", "Country"]
def task_func(text):

code prompt

Code

import pandas as pd
import regex as re
import seaborn as sns
import matplotlib.pyplot as plt
COLUMN_NAMES = ["Name", "Email", "Age", "Country"]
def task_func(text):

entry point

task_func

libs

  • regex
  • pandas
  • matplotlib
  • seaborn

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