benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf adcc187c-3767-5fc8-a33b-995fd5a2e86e

Problem

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

complete prompt

import pandas as pd
import matplotlib.pyplot as plt

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. Draw a line chart with unique values in the COLUMNS[-1] of the pandas DataFrame "df", grouped by the rest of the columns.
    - The x-label should be set to the string obtained by joining all the column names (except the last one) by the character "-".
    - The y-label should be set to the last column name.

    Parameters:
    - df (pandas.DataFrame): The DataFrame to be plotted.

    Returns:
    - tuple: A tuple containing:
        - pandas.DataFrame: The DataFrame of the analyzed data.
        - plt.Axes: The Axes object of the plotted line chart.

    Requirements:
    - pandas
    - 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)
       col1  col2  col3
    0     1     1     2
    1     1     2     1
    2     2     1     3
    3     2     2     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. Draw a line chart with unique values in the COLUMNS[-1] of the pandas DataFrame "df", grouped by the rest of the columns. - The x-label should be set to the string obtained by joining all the column names (except the last one) by the character "-". - The y-label should be set to the last column name.
The function should output with:
    tuple: A tuple containing:
    pandas.DataFrame: The DataFrame of the analyzed data.
    plt.Axes: The Axes object of the plotted line chart.
You should write self-contained code starting with:

Code

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

code prompt

Code

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

entry point

task_func

libs

  • pandas
  • matplotlib

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