benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf a6ed40ec-70e6-5cbe-8086-9b9d385bd94a

Problem

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

complete prompt

import pandas as pd
import numpy as np

def task_func(d):
    """
    Calculate mean, sum, max, min and standard deviation for 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 dictionaries of statistics.

    Raises:
    - ValueError: If input is not a list of dictionaries.

    Requirements:
    - pandas
    - numpy

    Examples:
    >>> data = [{'x': 1, 'y': 10, 'z': 5}, {'x': 3, 'y': 15, 'z': 6}, {'x': 2, 'y': 1, 'z': 7}]
    >>> task_func(data)
    {'x': {'mean': 2.0, 'sum': 6, 'max': 3, 'min': 1, 'std': 0.816496580927726}, 'y': {'mean': 8.666666666666666, 'sum': 26, 'max': 15, 'min': 1, 'std': 5.792715732327589}, 'z': {'mean': 6.0, 'sum': 18, 'max': 7, 'min': 5, 'std': 0.816496580927726}}
    >>> task_func([])
    {'x': None, 'y': None, 'z': None}
    >>> task_func([{'a': 1}])
    {'x': None, 'y': None, 'z': None}
    """

instruct prompt

Calculate mean, sum, max, min and standard deviation for the keys "x," "y" and "z" from a list of dictionaries "d."
The function should raise the exception for: ValueError: If input is not a list of dictionaries.
The function should output with:
    dict: A dictionary with keys as 'x', 'y', and 'z' and values as dictionaries of statistics.
You should write self-contained code starting with:

Code

import pandas as pd
import numpy as np
def task_func(d):

code prompt

Code

import pandas as pd
import numpy as np
def task_func(d):

entry point

task_func

libs

  • pandas
  • numpy

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