benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf f1ca5608-2f3d-5e7a-b0f2-bd0bbe333ea9

Problem

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

complete prompt

import pandas as pd
import matplotlib.pyplot as plt


def task_func(data_list):
    """
    Visualizes the scores of students over multiple tests using a line plot.

    The function takes in a list of dictionaries. Each dictionary contains the name of a student (key)
    and their score (value). It combines these dictionaries into a pandas DataFrame and plots a line graph
    of student scores over tests, where the x-axis represents the test number and the y-axis represents the score.
    Each student's scores are plotted as separate lines. Missing scores are handled by not plotting
    those specific data points, allowing for discontinuous lines where data is missing.

    Parameters:
    - data_list (list of dict): A list of dictionaries with student names as keys and their scores as values.

    Returns:
    - ax (matplotlib.axes._axes.Axes): The Axes object with the plotted data.

    Requirements:
    - pandas
    - matplotlib.pyplot

    Example:
    >>> data = [{'John': 5, 'Jane': 10}, {'John': 6, 'Jane': 8}, {'John': 5, 'Jane': 9}]
    >>> ax = task_func(data)
    >>> type(ax)
    <class 'matplotlib.axes._axes.Axes'>
    >>> ax.get_xticklabels()
    [Text(-0.25, 0, '−0.25'), Text(0.0, 0, '0.00'), Text(0.25, 0, '0.25'), Text(0.5, 0, '0.50'), Text(0.75, 0, '0.75'), Text(1.0, 0, '1.00'), Text(1.25, 0, '1.25'), Text(1.5, 0, '1.50'), Text(1.75, 0, '1.75'), Text(2.0, 0, '2.00'), Text(2.25, 0, '2.25')]
    """

instruct prompt

Visualizes the scores of students over multiple tests using a line plot. The function takes in a list of dictionaries. Each dictionary contains the name of a student (key) and their score (value). It combines these dictionaries into a pandas DataFrame and plots a line graph of student scores over tests, where the x-axis represents the test number and the y-axis represents the score. Each student's scores are plotted as separate lines. Missing scores are handled by not plotting those specific data points, allowing for discontinuous lines where data is missing.
The function should output with:
    ax (matplotlib.axes._axes.Axes): The Axes object with the plotted data.
You should write self-contained code starting with:

Code

import pandas as pd
import matplotlib.pyplot as plt
def task_func(data_list):

code prompt

Code

import pandas as pd
import matplotlib.pyplot as plt
def task_func(data_list):

entry point

task_func

libs

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