benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 2a51e3b0-29ab-5f8f-ba5d-82cfb93dc342

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(test_scores, student):
    """
    Convert a dictionary of test results into a pandas DataFrame and
    Calculate the average test score and the standard deviation for a particular student from this DataFrame.
    
    Parameters:
    test_scores (dictionary): The dictionary containing keys 'Student' and 'Score'.
        The Student values are of dtype int and contain student IDs. The Score 
        values are of dtype float.
    student (int): The specific student ID for which the average score needs to be calculated.
    
    Returns:
    np.array([float, float]): A numpy array containing the average score and the standard deviation for the student.
    DataFrame: the converted dictionary.

    Raises:
    ValueError: student is not present in the test_scores dataframe
                
    Requirements:
    - pandas
    - numpy
    
    Example:
    >>> STUDENTS = range(1, 101)
    >>> np.random.seed(10)
    >>> scores = {'Student': list(np.random.choice(STUDENTS, 50, replace=True)), 
    ...                        'Score': np.random.randint(50, 101, size=50)}
    >>> task_func(scores, 10)
    (array([70.        ,  7.07106781]),     Student  Score
    0        10     65
    1        16     68
    2        65     66
    3        29     57
    4        90     74
    5        94     61
    6        30     67
    7         9     96
    8        74     57
    9         1     61
    10       41     78
    11       37     83
    12       17     70
    13       12     82
    14       55     74
    15       89     94
    16       63     55
    17       34     54
    18       73     57
    19       79     74
    20       50     74
    21       52    100
    22       55     94
    23       78     84
    24       70     90
    25       14     65
    26       26     63
    27       14     74
    28       93     65
    29       87     56
    30       31     71
    31       31     92
    32       90     72
    33       13     61
    34       66     98
    35       32     62
    36       58     78
    37       37     82
    38       28     99
    39       19     65
    40       94     94
    41       78     90
    42       23     92
    43       24     95
    44       95     93
    45       12     83
    46       29    100
    47       75     95
    48       89     90
    49       10     75)

    >>> scores = {'Student': [1, 2, 1, 1], 'Score': [10, 1, 1, 1]}
    >>> task_func(scores, 1)
    (array([4.        , 5.19615242]),    Student  Score
    0        1     10
    1        2      1
    2        1      1
    3        1      1)
    """

instruct prompt

Convert a dictionary of test results into a pandas DataFrame and Calculate the average test score and the standard deviation for a particular student from this DataFrame. >>> scores = {'Student': [1, 2, 1, 1], 'Score': [10, 1, 1, 1]} >>> task_func(scores, 1) (array([4.        , 5.19615242]),    Student  Score 0        1     10 1        2      1 2        1      1 3        1      1)
The function should raise the exception for: ValueError: student is not present in the test_scores dataframe
The function should output with:
    np.array([float, float]): A numpy array containing the average score and the standard deviation for the student.
    DataFrame: the converted dictionary.
You should write self-contained code starting with:

Code

import pandas as pd
import numpy as np
def task_func(test_scores, student):

code prompt

Code

import pandas as pd
import numpy as np
def task_func(test_scores, student):

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