benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf a6a1bd97-b157-5474-93db-b86187080371

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
from collections import Counter

def task_func(student_grades, possible_grades=["A", "B", "C", "D", "F"]):
    """
    Create a report on students' grades in a class, including a count of each grade out of all possible grades
    and a bar chart. Note: Grades are case-insensitive but whitespace-sensitive. Those not in possible grades
    are ignored.

    Parameters:
    student_grades (list): List of student grades. Must not be empty.
    possible_grades (list, optional): List of possible grade values. Defaults to ['A', 'B', 'C', 'D', 'F'].

    Returns:
    Tuple[DataFrame, Axes]:
        - A pandas DataFrame with 'Grade' as the named index and their 'Count' as values.
        - A bar chart plot (matplotlib's Axes object) visualizing 'Grade Distribution', with 'Grade' on the
          x-axis and 'Number of Students' on the y-axis.

    Requirements:
    - pandas
    - matplotlib.pyplot
    - collections.Counter

    Example:
    >>> student_grades = ['A', 'B', 'B', 'C', 'A', 'D', 'F', 'B', 'A', 'C']
    >>> report_df, ax = task_func(student_grades)
    >>> type(ax)
    <class 'matplotlib.axes._axes.Axes'>
    >>> report_df
           Count
    Grade       
    A          3
    B          3
    C          2
    D          1
    F          1
    """

instruct prompt

Create a report on students' grades in a class, including a count of each grade out of all possible grades and a bar chart. Note: Grades are case-insensitive but whitespace-sensitive. Those not in possible grades are ignored.
The function should output with:
    Tuple[DataFrame, Axes]:
    A pandas DataFrame with 'Grade' as the named index and their 'Count' as values.
    A bar chart plot (matplotlib's Axes object) visualizing 'Grade Distribution', with 'Grade' on the
    x-axis and 'Number of Students' on the y-axis.
You should write self-contained code starting with:

Code

import pandas as pd
import matplotlib.pyplot as plt
from collections import Counter
def task_func(student_grades, possible_grades=["A", "B", "C", "D", "F"]):

code prompt

Code

import pandas as pd
import matplotlib.pyplot as plt
from collections import Counter
def task_func(student_grades, possible_grades=["A", "B", "C", "D", "F"]):

entry point

task_func

libs

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