benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 10c33acc-540e-5042-96f4-e3408cdab21a

Problem

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

complete prompt

import pandas as pd
import os

def task_func(original_file_location="test.xlsx", new_file_location="new_test.xlsx", sheet_name="Sheet1"):
    """
    Copies data from an Excel spreadsheet into a new Excel file, then reads the new Excel file and returns its contents.

    Parameters:
    - original_file_location (str): Path to the original Excel file. Defaults to 'test.xlsx'.
    - new_file_location (str): Path to save the new Excel file. Defaults to 'new_test.xlsx'.
    - sheet_name (str): Name of the sheet to load data from. Defaults to 'Sheet1'.

    Returns:
    - DataFrame: A pandas DataFrame representing the content of the new Excel file.

    Raises:
    - FileNotFoundError: If the original Excel file does not exist at the specified path.
    - ValueError: If the specified sheet does not exist in the workbook.

    Requirements:
    - pandas
    - os

    Example:
    >>> file_path, file_new_path, sheet_name = 'test.xlsx', 'new_test.xlsx', 'Sheet1'
    >>> create_dummy_excel(file_path, sheet_name)
    >>> df = task_func(file_path, file_new_path, sheet_name)
    >>> os.remove(file_path)
    >>> os.remove(file_new_path)
    """

instruct prompt

Copies data from an Excel spreadsheet into a new Excel file, then reads the new Excel file and returns its contents.
The function should raise the exception for: FileNotFoundError: If the original Excel file does not exist at the specified path. ValueError: If the specified sheet does not exist in the workbook.
The function should output with:
    DataFrame: A pandas DataFrame representing the content of the new Excel file.
You should write self-contained code starting with:

Code

import pandas as pd
import os
def task_func(original_file_location="test.xlsx", new_file_location="new_test.xlsx", sheet_name="Sheet1"):

code prompt

Code

import pandas as pd
import os
def task_func(original_file_location="test.xlsx", new_file_location="new_test.xlsx", sheet_name="Sheet1"):

entry point

task_func

libs

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