benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf e3fa0e77-4193-51ac-9e97-e71a02fff873

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
import matplotlib.pyplot as plt

# Constants
COLUMNS = ['col1', 'col2', 'col3']

def task_func(data):
    """
    You are given a list of elements. Each element is a list with the same length as COLUMNS, representing one row a dataframe df to create. Visualize the distribution of different values in a column "col3" of a pandas DataFrame df, grouped by "col1" and "col2," using a heatmap.

    Parameters:
    - data (list): A list of elements. Each element is a list with the same length as COLUMNS, representing one row of the dataframe to build.

    Returns:
    - tuple:
        pandas.DataFrame: The DataFrame of the analyzed data.
        plt.Axes: The heatmap visualization.

    Requirements:
    - pandas
    - seaborn
    - matplotlib

    Example:
    >>> data = [[1, 1, 1], [1, 1, 1], [1, 1, 2], [1, 2, 3], [1, 2, 3], [1, 2, 3], [2, 1, 1], [2, 1, 2], [2, 1, 3], [2, 2, 3], [2, 2, 3], [2, 2, 3]]
    >>> analyzed_df, ax = task_func(data)
    >>> print(analyzed_df)
    col2  1  2
    col1      
    1     2  1
    2     3  1
    """

instruct prompt

You are given a list of elements. Each element is a list with the same length as COLUMNS, representing one row a dataframe df to create. Visualize the distribution of different values in a column "col3" of a pandas DataFrame df, grouped by "col1" and "col2," using a heatmap.
The function should output with:
    tuple:
    pandas.DataFrame: The DataFrame of the analyzed data.
    plt.Axes: The heatmap visualization.
You should write self-contained code starting with:

Code

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Constants
COLUMNS = ['col1', 'col2', 'col3']
def task_func(data):

code prompt

Code

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
# Constants
COLUMNS = ['col1', 'col2', 'col3']
def task_func(data):

entry point

task_func

libs

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