Skip to content

Open source · free forever

svy — design-based survey analysis in Python.

The open-source engine under svyLab: estimation with correct variances, weighting and calibration, replicate weights, small-area estimation, and readers for SPSS, Stata, and SAS files — validated against R's survey package. Read the code, run it in a notebook, cite it.

pip install svy GitHub Getting started →
18
estimators validated against R, to at least six decimals
12–24×
faster than R on a million-row two-stage design
2020
open source since, as samplics
analysis.py
import svy

df = svy.read_parquet("wave1.parquet")
design = svy.Design(
    stratum="region", psu="cluster", wgt="final_wgt"
)
sample = svy.Sample(data=df, design=design)

est = sample.estimation.mean(
    ["income", "food_share"], by="urban_rural"
)
print(est)   # est · se · lci · uci · cv · deff · df

Prefer to try it first? Open the playground →

Documentation

The libraries

All on PyPI · github.com/samplics-org

Cite it

svy is the evolution of samplics, published in the Journal of Open Source Software. If it contributes to published work, please cite:

Diallo, M. S. (2021). samplics: a Python package for selecting, weighting and analyzing data from complex sampling designs. Journal of Open Source Software. doi:10.21105/joss.03376

Contribute

Issues, feature requests, and pull requests are welcome on GitHub. The comparison with R doubles as the validation suite, so a reproducible example against R's survey is the most useful bug report there is.

Open an issue →

Follow along

Releases, tutorials, and svyLab updates — a few emails a year.

Using svy in your organization?

svyLab runs your survey program on it.

Questionnaire and analysis plan in — weights, estimates, and a branded report out, every wave, with the method behind every number visible to a reviewer. Same engine; one governed place.