benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 0b5041a1-860c-5389-9581-21c6154aa74d

Problem

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

complete prompt

import requests
import json
import pandas as pd
import seaborn as sns

# Constants
HEADERS = {
    'accept': 'application/json'
}

def task_func(url, parameters):
    """
    Retrieve data from a specific API endpoint with the provided parameters, 
    convert the data into a pandas dataframe, and draw a heatmap to show 
    the correlation between numerical characteristics. The heatmap is 
    displayed and also returned for further use or testing.

    Parameters:
    url (str): The API endpoint URL.
    parameters (dict): The parameters to be sent with the GET request.

    Returns:
    tuple: A tuple containing:
        - DataFrame: The pandas DataFrame containing the data.
        - Axes: The matplotlib Axes object of the heatmap.

    Raises:
    - Thif function will raise a general Expection if the url is invalid, empty data, invalid data, and url cannot be accessed.

    Requirements:
    - requests
    - json
    - pandas
    - seaborn

    Example:
    >>> df, ax = task_func('https://api.example.com/data', {'param1': 'value1'})
    >>> df.iloc[0]['data']
    1
    """

instruct prompt

Retrieve data from a specific API endpoint with the provided parameters, convert the data into a pandas dataframe, and draw a heatmap to show the correlation between numerical characteristics. The heatmap is displayed and also returned for further use or testing.
The function should raise the exception for: Thif function will raise a general Expection if the url is invalid, empty data, invalid data, and url cannot be accessed.
The function should output with:
    tuple: A tuple containing:
    DataFrame: The pandas DataFrame containing the data.
    Axes: The matplotlib Axes object of the heatmap.
You should write self-contained code starting with:

Code

import requests
import json
import pandas as pd
import seaborn as sns
# Constants
HEADERS = {
    'accept': 'application/json'
}
def task_func(url, parameters):

code prompt

Code

import requests
import json
import pandas as pd
import seaborn as sns
# Constants
HEADERS = {
    'accept': 'application/json'
}
def task_func(url, parameters):

entry point

task_func

libs

  • pandas
  • json
  • requests
  • seaborn

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