benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 0a73b835-5e4e-5232-bfc0-d1637cad2eb1

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
import numpy as np

# Constants
PATTERN = r"([a-fA-F\d]{32})"

def task_func(df, column):
    """
    Find all matches of the regex pattern '([a-fA-F\ d] {32})' in a Pandas DataFrame column and count the occurrence of any unique match in the data.

    Parameters:
    df (DataFrame): The pandas DataFrame.
    column (str): The column in which to find the pattern.

    Returns:
    Series: A pandas Series with counts of each unique match.

    Requirements:
    - pandas
    - re
    - numpy

    Raises:
    - The function will raise KeyError if the "column" does not exist in input "df"

    Example:
    >>> data = pd.DataFrame({"text": ["6f96cfdfe5ccc627cadf24b41725caa4 gorilla", "6f96cfdfe5ccc627cadf24b41725caa4 banana", "1234567890abcdef1234567890abcdef apple"]})
    >>> counts = task_func(data, "text")
    >>> print(counts.index[0])
    6f96cfdfe5ccc627cadf24b41725caa4
    """

instruct prompt

Find all matches of the regex pattern '([a-fA-F\ d] {32})' in a Pandas DataFrame column and count the occurrence of any unique match in the data.
The function should raise the exception for: The function will raise KeyError if the "column" does not exist in input "df"
The function should output with:
    Series: A pandas Series with counts of each unique match.
You should write self-contained code starting with:

Code

import pandas as pd
import re
import numpy as np
# Constants
PATTERN = r"([a-fA-F\d]{32})"
def task_func(df, column):

code prompt

Code

import pandas as pd
import re
import numpy as np
# Constants
PATTERN = r"([a-fA-F\d]{32})"
def task_func(df, column):

entry point

task_func

libs

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