benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf f8493936-3a29-58a8-aa44-5c825b52a763

Problem

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

complete prompt

import os
import pandas as pd
from datetime import datetime

def task_func(excel_directory: str, file_name: str, column_name: str, start_date: str, end_date: str) -> pd.DataFrame:
    """
    Filters data in a specific date range from a column in an Excel file and returns a Pandas DataFrame of the filtered data.

    Parameters:
    excel_directory (str): The directory of the Excel file.
    file_name (str): The name of the Excel file.
    column_name (str): The name of the date column to filter.
    start_date (str): The start date in 'yyyy-mm-dd' format.
    end_date (str): The end date in 'yyyy-mm-dd' format.

    Returns:
    pd.DataFrame: A pandas DataFrame with the filtered data.

    Raises:
    FileNotFoundError: If the specified Excel file does not exist.
    ValueError: If start_date or end_date are in an incorrect format, or if column_name does not exist in the DataFrame.

    Example:
    >>> data_dir, file_name = './excel_files/', 'excel_file1.xls'
    >>> test_file = create_dummy_file(data_dir, file_name)
    >>> filtered_df = task_func(data_dir, file_name, 'Date', '2020-01-01', '2020-12-31')
    >>> os.remove(test_file)
    >>> os.rmdir(data_dir)
    >>> print(filtered_df.head())
       Unnamed: 0       Date     Value
    0           0 2020-01-01  0.823110
    1           1 2020-01-02  0.026118
    2           2 2020-01-03  0.210771
    3           3 2020-01-04  0.618422
    4           4 2020-01-05  0.098284
    
    Requirements:
    - os
    - pandas
    - datetime
    """

instruct prompt

Filters data in a specific date range from a column in an Excel file and returns a Pandas DataFrame of the filtered data.
The function should raise the exception for: FileNotFoundError: If the specified Excel file does not exist. ValueError: If start_date or end_date are in an incorrect format, or if column_name does not exist in the DataFrame.
The function should output with:
    pd.DataFrame: A pandas DataFrame with the filtered data.
You should write self-contained code starting with:

Code

import os
import pandas as pd
from datetime import datetime
def task_func(excel_directory: str, file_name: str, column_name: str, start_date: str, end_date: str) -> pd.DataFrame:

code prompt

Code

import os
import pandas as pd
from datetime import datetime
def task_func(excel_directory: str, file_name: str, column_name: str, start_date: str, end_date: str) -> pd.DataFrame:

entry point

task_func

libs

  • pandas
  • datetime
  • os

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