Skip to main content

Stratified random assignment using pandas

Project description

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.

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

stochatreat-0.2.4.tar.gz (6.4 MB view details)

Uploaded Source

Built Distribution

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

stochatreat-0.2.4-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file stochatreat-0.2.4.tar.gz.

File metadata

  • Download URL: stochatreat-0.2.4.tar.gz
  • Upload date:
  • Size: 6.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stochatreat-0.2.4.tar.gz
Algorithm Hash digest
SHA256 e737be3cbdac4e55e4d671902e30457330c4a615460beb43183e334eed162d6d
MD5 462acd9a874fc75fe042ae6cf7ae43e9
BLAKE2b-256 7124d5029594548784f54343be6b47413233d6f4440f1aebc1727d46e40a0e3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for stochatreat-0.2.4.tar.gz:

Publisher: release-and-publish.yml on manmartgarc/stochatreat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stochatreat-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: stochatreat-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for stochatreat-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2fe980fb423fc206b4c6a0a10d1da10ced1835ca8fb2741d594d685eccb52a3a
MD5 5e87e6aed797dd934e630f2be42bcbee
BLAKE2b-256 9b5b7f80e2656adb92c93d7209b36718b24361f916cd7377151e5be52b184487

See more details on using hashes here.

Provenance

The following attestation bundles were made for stochatreat-0.2.4-py3-none-any.whl:

Publisher: release-and-publish.yml on manmartgarc/stochatreat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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