scikit_posthocs.posthoc_tukey_hsd
- scikit_posthocs.posthoc_tukey_hsd(a: list | ndarray | DataFrame, val_col: str | None = None, group_col: str | None = None, sort: bool = True) DataFrame
Pairwise comparisons with Tukey’s honestly significant difference test, using SciPy’s scipy.stats.tukey_hsd implementation.
- Parameters:
a (array_like or pandas DataFrame) – Two-dimensional data containing the groups to compare. For a list or array, each row is a group; groups may have different lengths in a list.
val_col (str or int, optional) – Column containing observations when a is a DataFrame. Required for DataFrame input.
group_col (str or int, optional) – Column containing group labels when a is a DataFrame. Required for DataFrame input.
sort (bool, optional) – Sort by group and observation value before comparison. Default is True.
- Returns:
result – Pairwise p-values, with group labels as rows and columns and ones on the diagonal.
- Return type:
pandas.DataFrame
Notes
Refer to scipy.stats.tukey_hsd for details of the test.
Examples
>>> import scikit_posthocs as sp >>> x = [[1, 2, 3, 4, 5], [35, 31, 75, 40, 21], [10, 6, 9, 6, 1]] >>> p_values = sp.posthoc_tukey_hsd(x) >>> round(float(p_values.loc[1, 2]), 6) 0.000991