benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf 8abf9b67-9147-5644-902e-1edf5a92fea2
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
# Constants
COLUMNS = ['col1', 'col2', 'col3']
def task_func(data):
"""
You are given a list of elements. Each element of the list is a list of 3 values. Use this list of elements to build a dataframe with 3 columns 'col1', 'col2' and 'col3' and create a distribution of chart of the different values of "col3" grouped by "col1" and "col2" using seaborn.
The function's logic is as follows:
1. Build a pandas DataFrame by using list of elements. Make sure to name the columns as 'col1', 'col2' and 'col3', the constant COLUMNS is provided for this purpose.
2. Create a new dataframe by grouping the values in the column 'col3' by ['col1', 'col2'].
3. Reset the index of the newly created dataframe. This dataframe is the first element of the output tuple.
4. Create a distribution plot of the 'col3' column of the previous dataframe using seaborn. This plot is the second and last element of the output tuple.
- The xlabel (label for the x-axis) is set to the 'col3'.
Parameters:
data (list): The DataFrame to be visualized.
Returns:
tuple:
pandas.DataFrame: The DataFrame of the analyzed data.
plt.Axes: The seaborn plot object.
Requirements:
- pandas
- seaborn
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, plot = 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 of the list is a list of 3 values. Use this list of elements to build a dataframe with 3 columns 'col1', 'col2' and 'col3' and create a distribution of chart of the different values of "col3" grouped by "col1" and "col2" using seaborn. The function's logic is as follows: 1. Build a pandas DataFrame by using list of elements. Make sure to name the columns as 'col1', 'col2' and 'col3', the constant COLUMNS is provided for this purpose. 2. Create a new dataframe by grouping the values in the column 'col3' by ['col1', 'col2']. 3. Reset the index of the newly created dataframe. This dataframe is the first element of the output tuple. 4. Create a distribution plot of the 'col3' column of the previous dataframe using seaborn. This plot is the second and last element of the output tuple. - The xlabel (label for the x-axis) is set to the 'col3'.
The function should output with:
tuple:
pandas.DataFrame: The DataFrame of the analyzed data.
plt.Axes: The seaborn plot object.
You should write self-contained code starting with:
Code
import pandas as pd
import seaborn as sns
# Constants
COLUMNS = ['col1', 'col2', 'col3']
def task_func(data):
code prompt
Code
import pandas as pd
import seaborn as sns
# Constants
COLUMNS = ['col1', 'col2', 'col3']
def task_func(data):
entry point
task_func
libs
- pandas
- seaborn
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
initial import