benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf e8a4dd9b-238a-5c8e-9069-9a59b262e5ab

Problem

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

complete prompt

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd


def task_func(dictionary, key, value, n=100, bins=30, seed=0):
    """
    Updates the provided dictionary with a specified key-value pair and generates a random dataset of size 'n' 
    following a normal distribution. The mean and standard deviation of the distribution are set to the value 
    associated with the given key. Additionally, it returns a histogram of the generated dataset.
    
    Parameters:
    - dictionary (dict): The dictionary to be updated.
    - key (str): The key to be added to the dictionary.
    - value (str): The value to be associated with the provided key.
    - n (int, optional): The size of the random dataset to be generated. Default is 100.
    - bins (int, optional): The number of bins for the histogram. Default is 30.
    - seed (int, optional): The seed for the random number generator. Default is 0.
    
    Returns:
    - tuple: Updated dictionary and the generated dataset as a pandas Series along with the histogram plot.
    
    Requirements:
    - numpy
    - matplotlib
    - pandas

    Raises:
    - ValueError: If the provided value is not a number.
    
    Example:
    >>> d, data, ax = task_func({'key1': 10, 'key2': 20}, 'newkey', '25', n=500)
    >>> d
    {'key1': 10, 'key2': 20, 'newkey': '25'}
    >>> len(data)
    500
    """

instruct prompt

Updates the provided dictionary with a specified key-value pair and generates a random dataset of size 'n' following a normal distribution. The mean and standard deviation of the distribution are set to the value associated with the given key. Additionally, it returns a histogram of the generated dataset.
The function should raise the exception for: ValueError: If the provided value is not a number.
The function should output with:
    tuple: Updated dictionary and the generated dataset as a pandas Series along with the histogram plot.
You should write self-contained code starting with:

Code

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
def task_func(dictionary, key, value, n=100, bins=30, seed=0):

code prompt

Code

import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
def task_func(dictionary, key, value, n=100, bins=30, seed=0):

entry point

task_func

libs

  • pandas
  • numpy
  • matplotlib

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