benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf fa561d66-b9da-51f0-9666-624ceef4662c

Problem

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

complete prompt

import csv
import os
OUTPUT_DIR = './output'


def task_func(df, filename, output_dir=OUTPUT_DIR):
    """
    Save a Pandas DataFrame to a CSV file in a specified directory.

    This function takes a Pandas DataFrame and a filename as input and saves the DataFrame to a CSV file.
    The CSV file will be saved in the 'data' directory relative to the parent directory of this script.

    Parameters:
    - df (pandas.DataFrame): A Pandas DataFrame to be saved.
    - filename (str): The filename of the CSV file where the DataFrame will be saved.
    - output_dir (str, optional): the ouput directory.

    Returns:
    str: The absolute path of the saved CSV file.

    Requirements:
    - pandas
    - csv
    - os

    Examples:
    >>> import pandas as pd
    >>> df = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
    >>> 'data.csv' in task_func(df, 'data.csv')
    True
    """

instruct prompt

Save a Pandas DataFrame to a CSV file in a specified directory. This function takes a Pandas DataFrame and a filename as input and saves the DataFrame to a CSV file. The CSV file will be saved in the 'data' directory relative to the parent directory of this script.
The function should output with:
    str: The absolute path of the saved CSV file.
You should write self-contained code starting with:

Code

import csv
import os
OUTPUT_DIR = './output'
def task_func(df, filename, output_dir=OUTPUT_DIR):

code prompt

Code

import csv
import os
OUTPUT_DIR = './output'
def task_func(df, filename, output_dir=OUTPUT_DIR):

entry point

task_func

libs

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