benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf c3d6f133-900b-509a-992a-73606f3a4460

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
import itertools
from datetime import datetime, timedelta
import seaborn as sns

def task_func(df, fruits=None, days=None, seed=None, sales_lower_bound=1, sales_upper_bound=50):
    """
    Appends randomly generated sales data for specified fruits over a given range of days to a DataFrame, 
    and returns a seaborn boxplot of the sales.

    Parameters:
    - df (pd.DataFrame): Initial Empty DataFrame to append sales data to. Must be empty. 
    - fruits (List[str], optional): List of fruits for sales data. Defaults to ['Apple', 'Banana', 'Cherry', 'Date', 'Elderberry'].
    - days (List[datetime], optional): List of days for sales data. Defaults to the range from January 1, 2024, to January 7, 2024.
    - seed (int, optional): Seed for the random number generator. Defaults to None.
    - sales_lower_bound (int, optional): Lower bound for random sales values. Defaults to 1.
    - sales_upper_bound (int, optional): Upper bound for random sales values. Defaults to 50.

    Returns:
    Tuple[pd.DataFrame, sns.axisgrid.FacetGrid]: Updated DataFrame with sales data and a seaborn boxplot of the sales.

    Raises:
    TypeError: If 'df' is not a pandas DataFrame.
    ValueError: If 'df' is not empty or  If 'sales_lower_bound' is not less than 'sales_upper_bound'.

    Requirements:
    - pandas 
    - numpy
    - itertools
    - datetime
    - seaborn

    Example:
    >>> initial_df = pd.DataFrame()
    >>> report_df, plot = task_func(initial_df, seed=42)
    >>> print(report_df.head())
       Fruit        Day  Sales
    0  Apple 2024-01-01     39
    1  Apple 2024-01-02     29
    2  Apple 2024-01-03     15
    3  Apple 2024-01-04     43
    4  Apple 2024-01-05      8
    >>> plot.figure.show()

    """

instruct prompt

Appends randomly generated sales data for specified fruits over a given range of days to a DataFrame, and returns a seaborn boxplot of the sales.
The function should raise the exception for: TypeError: If 'df' is not a pandas DataFrame. ValueError: If 'df' is not empty or  If 'sales_lower_bound' is not less than 'sales_upper_bound'.
The function should output with:
    Tuple[pd.DataFrame, sns.axisgrid.FacetGrid]: Updated DataFrame with sales data and a seaborn boxplot of the sales.
You should write self-contained code starting with:

Code

import pandas as pd
import numpy as np
import itertools
from datetime import datetime, timedelta
import seaborn as sns
def task_func(df, fruits=None, days=None, seed=None, sales_lower_bound=1, sales_upper_bound=50):

code prompt

Code

import pandas as pd
import numpy as np
import itertools
from datetime import datetime, timedelta
import seaborn as sns
def task_func(df, fruits=None, days=None, seed=None, sales_lower_bound=1, sales_upper_bound=50):

entry point

task_func

libs

  • pandas
  • itertools
  • numpy
  • seaborn
  • datetime

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