benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf b3769572-ba3c-56ea-9a71-84b988b02689

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(L):
    """
    Draw a histogram of all elements in a nested list 'L' and return the Axes object of the plot.

    The function first uses Numpy to handle array operations, checking for correct input type
    while ignoring empty sublists. It then plots the histogram using pandas, assigning
    each unique value its own bin and plotting the histogram with rwidth 0.8.

    Parameters:
    L (list of list of int): Nested list of integers.

    Returns:
    ax (matplotlib.axes._axes.Axes): The Axes object of the histogram plot.

    Raises:
    If the input is not a list of list of integers, a TypeError is raised.
    
    Requirements:
    - pandas
    - numpy

    Example:
    >>> ax = task_func([[1,2,3],[4,5,6]])
    >>> type(ax)
    <class 'matplotlib.axes._axes.Axes'>
    >>> ax.get_xticklabels()
    [Text(0.0, 0, '0'), Text(1.0, 0, '1'), Text(2.0, 0, '2'), Text(3.0, 0, '3'), Text(4.0, 0, '4'), Text(5.0, 0, '5'), Text(6.0, 0, '6'), Text(7.0, 0, '7')]
    """

instruct prompt

Draw a histogram of all elements in a nested list 'L' and return the Axes object of the plot. The function first uses Numpy to handle array operations, checking for correct input type while ignoring empty sublists. It then plots the histogram using pandas, assigning each unique value its own bin and plotting the histogram with rwidth 0.8.
The function should raise the exception for: If the input is not a list of list of integers, a TypeError is raised.
The function should output with:
    ax (matplotlib.axes._axes.Axes): The Axes object of the histogram plot.
You should write self-contained code starting with:

Code

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

code prompt

Code

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

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