benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 7243f58b-9300-584a-9746-d67f875288ed

Problem

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

complete prompt

import pandas as pd
import seaborn as sns


def task_func(array):
    """Generates a DataFrame and heatmap from a 2D list.

    This function takes a 2D list and returns a pandas DataFrame and a seaborn heatmap
    representing the correlation matrix of the DataFrame. Assumes sublists of length 5.
    Also assumes DataFrame columns: 'A', 'B', 'C', 'D', 'E'.

    Parameters:
    - array (list of list of int): 2D list with sublists of length 5. Must not be empty.

    Returns:
    - DataFrame: Constructed from the input 2D list.
    - heatmap: Seaborn heatmap of the DataFrame's correlation matrix.

    Requirements:
    - pandas
    - seaborn

    Raises:
    - ValueError: If the input array is empty or contains sublists of varying lengths.
    
    Example:
    >>> df, ax = task_func([[1, 2, 3, 4, 5], [5, 4, 3, 2, 1]])
    >>> df
       A  B  C  D  E
    0  1  2  3  4  5
    1  5  4  3  2  1
    >>> ax
    <Axes: >
    """

instruct prompt

Generates a DataFrame and heatmap from a 2D list. This function takes a 2D list and returns a pandas DataFrame and a seaborn heatmap representing the correlation matrix of the DataFrame. Assumes sublists of length 5. Also assumes DataFrame columns: 'A', 'B', 'C', 'D', 'E'.
The function should raise the exception for: ValueError: If the input array is empty or contains sublists of varying lengths.
The function should output with:
    DataFrame: Constructed from the input 2D list.
    heatmap: Seaborn heatmap of the DataFrame's correlation matrix.
You should write self-contained code starting with:

Code

import pandas as pd
import seaborn as sns
def task_func(array):

code prompt

Code

import pandas as pd
import seaborn as sns
def task_func(array):

entry point

task_func

libs

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