benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf e3841028-f1ab-55de-8e1c-b17e0c226465
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(data):
"""
Analyze a dataset by calculating the average of values across each row and visualizing the correlation matrix as a
heatmap.
Parameters:
data (numpy.array): 2D array where each row represents a record and each column represents a feature
Returns:
tuple: A tuple containing:
- DataFrame: A pandas DataFrame enhanced with an 'Average' column that represents the mean across each row.
- Axes: The matplotlib Axes object showing the heatmap of the correlations.
Requirements:
- pandas
- numpy
- seaborn
Raises:
ValueError: If the input data is not a 2D array or if it contains non-numeric data.
Example:
>>> data = np.array([[1, 2, 3, 4, 5, 6, 7, 8], [8, 7, 6, 5, 4, 3, 2, 1]])
>>> df, ax = task_func(data)
>>> print(df['Average'].to_string(index=False))
4.5
4.5
"""
instruct prompt
Analyze a dataset by calculating the average of values across each row and visualizing the correlation matrix as a heatmap.
The function should raise the exception for: ValueError: If the input data is not a 2D array or if it contains non-numeric data.
The function should output with:
tuple: A tuple containing:
DataFrame: A pandas DataFrame enhanced with an 'Average' column that represents the mean across each row.
Axes: The matplotlib Axes object showing the heatmap of the correlations.
You should write self-contained code starting with:
Code
import pandas as pd
import seaborn as sns
def task_func(data):
code prompt
Code
import pandas as pd
import seaborn as sns
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