audit-labs/audit-tools

A collection of scripts, queries, and other goodies you can use in an audit. audit automation compliance evidence scripts

Commit 982249b041

982249b041600983b0d233d6c93f74597ad49234

parent: a70cee9b1e

Unsigned

cmc <hello@cleberg.net> · 2026-08-07 02:13 UTC

Make sampling/sample.py reproducible and point to the real tool

Seed the example draw and note that audit_sample.py / sampling_tool records
population hash, seed, method, and version for defensible sampling.

Layout: unified · split

sampling/sample.py +12 −2
@@ -1,5 +1,11 @@
11"""
22Creates a sample from a CSV or Excel file based on user-defined SAMPLE_SIZE.
3
4NOTE: This is a minimal teaching snippet. For real fieldwork use the
5`audit_sample.py` CLI (or the `sampling_tool` package), which records the
6population hash, seed, method, and tool version in a manifest so the sample is
7reproducible and defensible. This file fixes a SEED only so the example itself is
8repeatable; it does not emit that provenance.
39"""
410
511# Import packages
@@ -8,6 +14,10 @@ import pandas as pd
814# Define the sample size
915SAMPLE_SIZE = 25
1016
17# A fixed seed makes the draw reproducible: same population + same seed => same
18# rows. Record the seed alongside any sample you rely on.
19SEED = 20260707
20
1121# Import the data to a pandas DataFrame
1222df = pd.read_csv("FILENAME_GOES_HERE.csv")
1323
@@ -19,7 +29,7 @@ df = pd.read_csv("FILENAME_GOES_HERE.csv")
1929print("Dataframe size (rows, columns): ", df.shape)
2030
2131# Sample
22sample = df.sample(SAMPLE_SIZE)
32sample = df.sample(SAMPLE_SIZE, random_state=SEED)
2333print("Sample size: ", SAMPLE_SIZE)
2434print("Sample:\n", sample)
2535
@@ -31,4 +41,4 @@ print("Sample:\n", sample)
3141#
3242# # Sample Size: 25 + 5 replacement samples
3343# SAMPLE_SIZE = 30
34# sample = df.sample(SAMPLE_SIZE, replace=True)
44# sample = df.sample(SAMPLE_SIZE, replace=True, random_state=SEED)