Skip to main content

Beginner-friendly side-by-side boxplots and two-sample tests (t-test / Mann–Whitney).

Project description

boxTestpy

boxTestpy is a beginner-friendly Python package for creating side-by-side boxplots and performing basic two-sample statistical tests (t-test or Mann–Whitney U test) with publication-ready plots. It simplifies data visualization and statistical analysis for beginners and researchers.


Features

  • Side-by-side boxplots for a two-level categorical variable
  • Normality check using Shapiro–Wilk test
  • Automatic selection of independent t-test or Mann–Whitney U test
  • Pastel color palette for clean plots
  • Optional statistical annotation on plots
  • Works with pandas DataFrames

Installation

pip install boxTestpy

For plotting support:

pip install matplotlib seaborn pandas

Quick Start

import pandas as pd
import matplotlib.pyplot as plt
import boxtestpy as btp

# Public health dataset: Blood Pressure (systolic)
data = {
    "group": ["Control"]*10 + ["Treatment"]*10,
    "blood_pressure": [
        120, 122, 118, 121, 119, 123, 117, 124, 120, 122,   # Control group
        115, 118, 116, 117, 119, 114, 116, 118, 117, 115    # Treatment group
    ]
}

df = pd.DataFrame(data)

# Side-by-side boxplot with statistical annotation
ax = btp.boxplot_side_by_side(df, group_col="group", value_col="blood_pressure")
plt.show()

# Statistical test
x = df[df["group"] == "Control"]["blood_pressure"]
y = df[df["group"] == "Treatment"]["blood_pressure"]
result = btp.compare_two_groups(x, y)
print("Statistical Test Results:", result)

# Custom pastel colors (optional)
colors = ["#f0106dff", "#adf010ff"]  # pastel red and blue

ax = btp.boxplot_side_by_side(
    df,
    group_col="group",
    value_col="blood_pressure",
    colors=colors
)
plt.show()

Functions

boxplot_side_by_side(df, group_col, value_col)

  • Creates a side-by-side boxplot for a two-level categorical variable.
  • Automatically shows a pastel-colored plot with optional statistical annotation.

compare_two_groups(x, y)

  • Performs Shapiro–Wilk normality tests on both groups.
  • Runs t-test if both groups are normal, or Mann–Whitney U test if not.
  • Returns a dictionary with test names and p-values.

License

MIT License. See LICENSE for details.


Contributing

Contributions, bug reports, and feature requests are welcome. Open an issue or pull request on GitHub.


Contributors

  • Arkaprabha Sau (Author, Creator, Maintainer)
  • Santanu Phadikar (Contributor)
  • Ishita Bhakta (Contributor)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

boxtestpy-0.2.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

boxtestpy-0.2.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file boxtestpy-0.2.0.tar.gz.

File metadata

  • Download URL: boxtestpy-0.2.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for boxtestpy-0.2.0.tar.gz
Algorithm Hash digest
SHA256 59997aabc85e65a00a4c66c66eedf43ba7ae4cba0f4daf1264f03cbe1912b5c0
MD5 d070d62b798046a5458554570bda374e
BLAKE2b-256 a03dbc12dba5f5d3fb967b36c6d68dd5075cd5cac70e21549521212af44d02cd

See more details on using hashes here.

File details

Details for the file boxtestpy-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: boxtestpy-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for boxtestpy-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 57878d67207a349824e1e014e4d030a28779d9a2761b45fac2219b9a15067ec9
MD5 ff1595306dce0f10c3855cb1afe9529a
BLAKE2b-256 1f440d00a3ac73326d7cb4b489d16aa6aa10be6edd87990b1a65a4b5e6ba8aae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page