benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 6448db4b-7fcb-5b96-9269-7690568b9bbf

Problem

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

complete prompt

import urllib.request
import os
import json
import pandas as pd

# Constants
TARGET_JSON_FILE = "downloaded_file.json"


def task_func(url):
    """
    This function retrieves a JSON file from the given URL using urllib.request.urlretrieve,
    temporarily saving it as 'downloaded_file.json'. It then opens and reads this file,
    converts the JSON content into a pandas DataFrame, and finally deletes the temporary JSON file.

    Parameters:
    url (str): The URL of the JSON file to be downloaded.

    Returns:
    pandas.DataFrame: A DataFrame constructed from the JSON data in the downloaded file.

    Requirements:
    - urllib.request
    - os
    - json
    - pandas

    Example:
    >>> task_func('http://example.com/employees.json')
        name  age           city
    0  Alice   25       New York
    1    Bob   30  San Francisco
    """

instruct prompt

This function retrieves a JSON file from the given URL using urllib.request.urlretrieve, temporarily saving it as 'downloaded_file.json'. It then opens and reads this file, converts the JSON content into a pandas DataFrame, and finally deletes the temporary JSON file.
The function should output with:
    pandas.DataFrame: A DataFrame constructed from the JSON data in the downloaded file.
You should write self-contained code starting with:

Code

import urllib.request
import os
import json
import pandas as pd
# Constants
TARGET_JSON_FILE = "downloaded_file.json"
def task_func(url):

code prompt

Code

import urllib.request
import os
import json
import pandas as pd
# Constants
TARGET_JSON_FILE = "downloaded_file.json"
def task_func(url):

entry point

task_func

libs

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