benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 42b50af8-0116-51c4-ac75-de1c32b4afd5

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):
    """
    Combine a list of dictionaries with the same keys (fruit names) into a single pandas dataframe
    where NA/NaN values are filled with 0, then generate a line chart of sales.
    The chart should have title 'Fruit Sales over Time', x-axis 'Time', and y-axis 'Sales Quantity'.

    Parameters:
    - data (list): A list of dictionaries. Each element correspond to sales quantities at a point in time,
                   where keys are fruit names (str) and values are sales quantities (int). If values
                   are not the expected type, this function raises TypeError.

    Returns:
    - matplotlib.axes._axes.Axes: The generated plot's Axes object.

    Requirements:
    - pandas
    - matplotlib.pyplot

    Example:
    >>> task_func([{'apple': 10, 'banana': 15, 'cherry': 12, 'durian': 0}])
    <Axes: title={'center': 'Fruit Sales over Time'}, xlabel='Time', ylabel='Sales Quantity'>
    >>> task_func([{'apple': 10, 'banana': 15, 'cherry': 12}, {'apple': 12, 'banana': 20, 'cherry': 14}])
    <Axes: title={'center': 'Fruit Sales over Time'}, xlabel='Time', ylabel='Sales Quantity'>
    """

instruct prompt

Combine a list of dictionaries with the same keys (fruit names) into a single pandas dataframe where NA/NaN values are filled with 0, then generate a line chart of sales. The chart should have title 'Fruit Sales over Time', x-axis 'Time', and y-axis 'Sales Quantity'.
The function should output with:
    matplotlib.axes._axes.Axes: The generated plot's Axes object.
You should write self-contained code starting with:

Code

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

code prompt

Code

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

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