benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 87c2c69b-4c1d-5344-b20e-d495d2c25309

Problem

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

complete prompt

import pandas as pd
import json


def task_func(data: dict, output_path: str = "./default_data_output.json") -> str:
    """
    Converts the given DataFrame to a dictionary, dropping the column named 'c'
    if it exists, and then saves it as a JSON file.

    Parameters:
    - data (dict): The input data dictionary.
    - output_path (str, optional): The path where the JSON file should be saved. Default is './default_data_output.json'.

    Returns:
    - str: Path where the JSON file was saved.

    Requirements:
    - pandas
    - json

    Example:
    >>> task_func({'a': [1,2], 'b': [3,4], 'c': [5,6]})
    './default_data_output.json'
    >>> print(json.load(open(task_func({'a': [1,2], 'b': [3,4], 'c': [5,6]})))
    {'a': {'0': 1, '1': 2}, 'b': {'0': 3, '1': 4}}
    >>> task_func({'a': [1,2], 'b': [3,4], 'c': [5,6]}, 'custom/path/results.json')
    'custom/path/results.json'
    >>> print(json.load(open(task_func({'a': [1,2], 'b': [3,4], 'c': [5,6]}, 'custom/path/results.json')))
    {'a': {'0': 1, '1': 2}, 'b': {'0': 3, '1': 4}}
    """

instruct prompt

Converts the given DataFrame to a dictionary, dropping the column named 'c' if it exists, and then saves it as a JSON file.
The function should output with:
    str: Path where the JSON file was saved.
You should write self-contained code starting with:

Code

import pandas as pd
import json
def task_func(data: dict, output_path: str = "./default_data_output.json") -> str:

code prompt

Code

import pandas as pd
import json
def task_func(data: dict, output_path: str = "./default_data_output.json") -> str:

entry point

task_func

libs

  • pandas
  • json

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