benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 2e25ccdb-b50e-5deb-af2c-44ae3529cf49

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 itertools import cycle

def task_func(df, groups=['A', 'B', 'C', 'D', 'E']):
    """
    Analyzes the groups in a DataFrame by plotting a scatter plot of the ordinals against the values for each group.

    Parameters:
    df (DataFrame): The DataFrame with columns 'group', 'date', and 'value'.
    groups (list, optional): List of group identifiers. Defaults to ['A', 'B', 'C', 'D', 'E'].

    Returns:
    matplotlib.axes.Axes: The Axes object with the scatter plot.
    The Axes object will have a title 'Scatterplot of Values for Each Group Over Time', 
               x-axis labeled as 'Date (ordinal)', and y-axis labeled as 'Value'.


    Raises:
    ValueError: If 'df' is not a DataFrame or lacks required columns.

    Requirements:
    - pandas
    - matplotlib.pyplot
    - itertools

    Example:
    >>> df = pd.DataFrame({
    ...     "group": ["A", "A", "A", "B", "B"],
    ...     "date": pd.to_datetime(["2022-01-02", "2022-01-13", "2022-02-01", "2022-02-23", "2022-03-05"]),
    ...     "value": [10, 20, 16, 31, 56],
    ...     })
    >>> ax = task_func(df)
    >>> ax.figure.show()  # This will display the plot
    """

instruct prompt

Analyzes the groups in a DataFrame by plotting a scatter plot of the ordinals against the values for each group.
The function should raise the exception for: ValueError: If 'df' is not a DataFrame or lacks required columns.
The function should output with:
    matplotlib.axes.Axes: The Axes object with the scatter plot.
    The Axes object will have a title 'Scatterplot of Values for Each Group Over Time',
    x-axis labeled as 'Date (ordinal)', and y-axis labeled as 'Value'.
You should write self-contained code starting with:

Code

import pandas as pd
import matplotlib.pyplot as plt
from itertools import cycle
def task_func(df, groups=['A', 'B', 'C', 'D', 'E']):

code prompt

Code

import pandas as pd
import matplotlib.pyplot as plt
from itertools import cycle
def task_func(df, groups=['A', 'B', 'C', 'D', 'E']):

entry point

task_func

libs

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