benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf a1b0fdaf-b948-51be-8ec7-fdf5514fa3a0

Problem

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

complete prompt

import pandas as pd
from datetime import datetime
import holidays

def task_func(start_date=datetime(2023, 1, 1), end_date=datetime(2023, 12, 31), country='US'):
    """
    Create a list of business days between two dates, excluding weekends and specified country's public holidays.

    Parameters:
    start_date (datetime): The start date. Default is January 1, 2023.
    end_date (datetime): The end date. Default is December 31, 2023. 
    country (str): ISO country code to determine public holidays. Default is 'US'.

    Returns:
    list[datetime]: A list of business days (as datetime objects). The start date and end date is included to process. 

    Raises:
    ValueError: If start_date is not a datetime object or is after end_date.
    ValueError: If end_date is not a datetime object or is before start_date.

    Requirements:
    - pandas
    - datetime
    - holidays

    Note:
    - The function depends on the 'holidays' package for fetching public holidays.
    - Ensure 'pandas' and 'holidays' packages are installed.

    Example:
    >>> business_days = task_func()
    >>> print(business_days[0])
    2023-01-03 00:00:00
    """

instruct prompt

Create a list of business days between two dates, excluding weekends and specified country's public holidays.
Note that: The function depends on the 'holidays' package for fetching public holidays. Ensure 'pandas' and 'holidays' packages are installed.
The function should raise the exception for: ValueError: If start_date is not a datetime object or is after end_date. ValueError: If end_date is not a datetime object or is before start_date.
The function should output with:
    list[datetime]: A list of business days (as datetime objects). The start date and end date is included to process.
You should write self-contained code starting with:

Code

import pandas as pd
from datetime import datetime
import holidays
def task_func(start_date=datetime(2023, 1, 1), end_date=datetime(2023, 12, 31), country='US'):

code prompt

Code

import pandas as pd
from datetime import datetime
import holidays
def task_func(start_date=datetime(2023, 1, 1), end_date=datetime(2023, 12, 31), country='US'):

entry point

task_func

libs

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