Skip to main content

Stochatreat

stochatreat logo

typing-and-tests Coverage Status pypi PyPI Downloads Conda conda-downloads Hatch project linting - Ruff ty License - MIT


Stratified random treatment assignment using pandas. Designed for randomized controlled trials (RCTs) — assign treatments across any number of strata, with equal or unequal probabilities, and let stochatreat handle the misfits.

Installation

pip install stochatreat
# or
conda install -c conda-forge stochatreat

Quick start

from stochatreat import stochatreat
import numpy as np
import pandas as pd

df = pd.DataFrame({"id": range(1000), "nhood": np.random.randint(1, 6, 1000)})

treats = stochatreat(data=df, stratum_cols="nhood", treats=2, idx_col="id", random_state=42)
df = df.merge(treats, how="left", on="id")

For full documentation and examples visit manmartgarc.github.io/stochatreat.

Contributing

Read the contributing guide.

Metadata

Release files for stochatreat 0.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stochatreat 0.2.5
File Size Uploaded Provenance Actions
stochatreat-0.2.5.tar.gz 6.4 MB With provenance Details for stochatreat-0.2.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for stochatreat 0.2.5
File Interpreter ABI Platform Actions
stochatreat-0.2.5-py3-none-any.whl Python 3 none any Details for stochatreat-0.2.5-py3-none-any.whl

Total release size: 6.4 MB

Release files / stochatreat-0.2.5.tar.gz

Download URL stochatreat-0.2.5.tar.gz
Size 6.4 MB
Tags Source
SHA-256 checksum
How to use checksums
000b95f6997b7fdc67c3cf52461e44f77123d3f1546065d9d1855957c91e1fb2
BLAKE2b-256 checksum
How to use checksums
5d8a266545d9d3d58c0ccc295baadd254bf09c5963c58173af64e281c1ce5ee7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / stochatreat-0.2.5-py3-none-any.whl

Download URL stochatreat-0.2.5-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
28e8fbc71d977cb58a6f23c1c72a1c478ae8a410971d9bab6fc5ec83cc757ab0
BLAKE2b-256 checksum
How to use checksums
b7854a2bd99f15892edb98d971ca7ab73588892779f7c41f511490564f835d36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Security for stochatreat 0.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for stochatreat-0.2.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page