benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 23e3fbe4-2837-5678-9d9d-4acca6d12e4a

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


def task_func(filename: str) -> pd.DataFrame:
    """
    Read a CSV file into a Pandas DataFrame and then delete the entire contents of the original file.

    Parameters:
    - filename (str): The name of the CSV file to read and erase.

    Returns:
    - DataFrame: The contents of the CSV file as a pandas DataFrame.

    Raises:
    - FileNotFoundError: If the CSV file does not exist.

    Requirements:
    - os
    - pandas

    Example:
    >>> import os
    >>> from unittest.mock import patch
    >>> with patch('os.path.exists', return_value=False):
    ...     task_func('nonexistent.csv')
    Traceback (most recent call last):
        ...
    FileNotFoundError: No such file: 'nonexistent.csv'
    """

instruct prompt

Read a CSV file into a Pandas DataFrame and then delete the entire contents of the original file.
The function should raise the exception for: FileNotFoundError: If the CSV file does not exist.
The function should output with:
    DataFrame: The contents of the CSV file as a pandas DataFrame.
You should write self-contained code starting with:

Code

import os
import pandas as pd
def task_func(filename: str) -> pd.DataFrame:

code prompt

Code

import os
import pandas as pd
def task_func(filename: str) -> pd.DataFrame:

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