benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf f5ddffb7-e0e9-5b5f-8526-5d20988fad5f

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
from scipy import stats

# Constants
COLUMN_NAMES = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']


def task_func(data):
    """
    Processes a given dataset to compute the average of each row, plots the distribution of these averages,
    and evaluates their normality. The function returns these averages as an additional column in a DataFrame,
    the plot of the distribution, and the p-value from the normality test if applicable.

    Parameters:
    data (numpy.array): A 2D numpy array with eight columns representing different data types or categories, with a
    shape of (n_samples, 8).

    Returns:
    tuple: Contains three elements:
        - DataFrame: A pandas DataFrame with the original data and an added 'Average' column.
        - Axes object: The Axes object from the seaborn distribution plot of the averages.
        - float or None: The p-value from the normality test on the averages, or None
        if the test could not be conducted.

    Requirements:
    - pandas
    - seaborn
    - scipy

    Raises:
    ValueError: If the input data does not have exactly eight columns.

    Note:
    The function uses seaborn's distplot for visualization and scipy's normaltest for statistical analysis.
    It requires at least 20 data points to perform the normality test.

    Example:
    >>> import numpy as np
    >>> data = np.array([[1, 2, 3, 4, 4, 3, 7, 1], [6, 2, 3, 4, 3, 4, 4, 1]])
    >>> df, ax, p_value = task_func(data)
    >>> print(df)
       A  B  C  D  E  F  G  H  Average
    0  1  2  3  4  4  3  7  1    3.125
    1  6  2  3  4  3  4  4  1    3.375
    >>> print(p_value)
    None
    """

instruct prompt

Processes a given dataset to compute the average of each row, plots the distribution of these averages, and evaluates their normality. The function returns these averages as an additional column in a DataFrame, the plot of the distribution, and the p-value from the normality test if applicable.
Note that: The function uses seaborn's distplot for visualization and scipy's normaltest for statistical analysis. It requires at least 20 data points to perform the normality test.
The function should raise the exception for: ValueError: If the input data does not have exactly eight columns.
The function should output with:
    tuple: Contains three elements:
    DataFrame: A pandas DataFrame with the original data and an added 'Average' column.
    Axes object: The Axes object from the seaborn distribution plot of the averages.
    float or None: The p-value from the normality test on the averages, or None
    if the test could not be conducted.
You should write self-contained code starting with:

Code

import pandas as pd
import seaborn as sns
from scipy import stats
# Constants
COLUMN_NAMES = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
def task_func(data):

code prompt

Code

import pandas as pd
import seaborn as sns
from scipy import stats
# Constants
COLUMN_NAMES = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
def task_func(data):

entry point

task_func

libs

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