benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 99d2a0eb-74a1-52ba-a246-adf0ee1c4e70

Problem

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

complete prompt

import pandas as pd
from scipy.stats import zscore
import matplotlib.pyplot as plt

def task_func(df):
    """
    Processes a pandas DataFrame with 'Date' and 'Value' columns. The 'Value' column contains lists of numbers. 
    Converts 'Date' to datetime, splits 'Value' lists into separate columns, calculates Z-scores, 
    and creates a box plot for Z-scores over time.

    Parameters:
    df (DataFrame): A pandas DataFrame with two columns: 'Date' (date strings) and 'Value' (lists of numbers).

    Returns:
    DataFrame: With original 'Value' lists split into separate columns and replaced with Z-scores.
    Figure: A matplotlib figure of a box plot of Z-scores over time.

    Note:
    - This function use "Z-Scores Over Time" for the plot title.
    - This function use "Date" and "Z-Score" as the xlabel and ylabel respectively.

    Raises:
    - This function will raise KeyError if the DataFrame does not have the 'Date' and 'Value' columns.

    Requirements:
    - pandas
    - scipy.stats.zscore
    - matplotlib.pyplot

    Example:
    >>> df = pd.DataFrame([['2021-01-01', [8, 10, 12]], ['2021-01-02', [7, 9, 11]]], columns=['Date', 'Value'])
    >>> zscore_df, fig = task_func(df)
    >>> print(zscore_df.shape)
    (2, 4)
    >>> plt.close()
    """

instruct prompt

Processes a pandas DataFrame with 'Date' and 'Value' columns. The 'Value' column contains lists of numbers. Converts 'Date' to datetime, splits 'Value' lists into separate columns, calculates Z-scores, and creates a box plot for Z-scores over time.
Note that: This function use "Z-Scores Over Time" for the plot title. This function use "Date" and "Z-Score" as the xlabel and ylabel respectively.
The function should raise the exception for: This function will raise KeyError if the DataFrame does not have the 'Date' and 'Value' columns.
The function should output with:
    DataFrame: With original 'Value' lists split into separate columns and replaced with Z-scores.
    Figure: A matplotlib figure of a box plot of Z-scores over time.
You should write self-contained code starting with:

Code

import pandas as pd
from scipy.stats import zscore
import matplotlib.pyplot as plt
def task_func(df):

code prompt

Code

import pandas as pd
from scipy.stats import zscore
import matplotlib.pyplot as plt
def task_func(df):

entry point

task_func

libs

  • pandas
  • matplotlib
  • scipy

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