benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 4d8580c9-2897-522a-b8e5-3891c7732573

Problem

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

complete prompt

import pandas as pd
from collections import Counter

def task_func(d):
    """
    Count the occurrence of values with the keys "x," "y" and "z" from a list of dictionaries "d."

    Parameters:
    d (list): A list of dictionaries.

    Returns:
    dict: A dictionary with keys as 'x', 'y', and 'z' and values as Counter objects.

    Requirements:
    - pandas
    - collections.Counter

    Example:
    >>> data = [{'x': 1, 'y': 10, 'z': 5}, {'x': 3, 'y': 15, 'z': 5}, {'x': 2, 'y': 1, 'z': 7}]
    >>> print(task_func(data))
    {'x': Counter({1: 1, 3: 1, 2: 1}), 'y': Counter({10: 1, 15: 1, 1: 1}), 'z': Counter({5: 2, 7: 1})}
    >>> data = [{'x': 2, 'y': 10}, {'y': 15, 'z': 5}, {'x': 2, 'z': 7}]
    >>> print(task_func(data))
    {'x': Counter({2.0: 2}), 'y': Counter({10.0: 1, 15.0: 1}), 'z': Counter({5.0: 1, 7.0: 1})}
    """

instruct prompt

Count the occurrence of values with the keys "x," "y" and "z" from a list of dictionaries "d."
The function should output with:
    dict: A dictionary with keys as 'x', 'y', and 'z' and values as Counter objects.
You should write self-contained code starting with:

Code

import pandas as pd
from collections import Counter
def task_func(d):

code prompt

Code

import pandas as pd
from collections import Counter
def task_func(d):

entry point

task_func

libs

  • pandas
  • collections

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