benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 770b9150-7cfe-5f35-b993-c11735427bb3

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
OUTPUT_DIR = './output'


def task_func(df, filename, output_dir=OUTPUT_DIR):
    """
    Save a Pandas DataFrame to a JSON file in a specified directory.
    
    Parameters:
    - df (DataFrame): A Pandas DataFrame to be saved.
    - filename (str): The filename of the JSON file where the DataFrame will be saved.
    - output_dir (str, optional): the ouput directory.
    
    Returns:
    str: The full file path where the DataFrame is saved.
    
    Requirements:
    - os
    - pandas

    Note:
    - The function manipulates a Pandas DataFrame and saves it as a JSON file.

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

instruct prompt

Save a Pandas DataFrame to a JSON file in a specified directory.
Note that: The function manipulates a Pandas DataFrame and saves it as a JSON file.
The function should output with:
    str: The full file path where the DataFrame is saved.
You should write self-contained code starting with:

Code

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

code prompt

Code

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

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