audit-labs/audit-tools

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

Commit 1560a4e282

1560a4e282c6228303e42f8940008f462c328c22

parent: dd92950136

Unsigned

cmc <hello@cleberg.net> · 2024-10-19 16:26 UTC

add sample.py

Layout: unified · split

sample.py added +30
@@ -0,0 +1,30 @@
1# Import packages
2import pandas as pd
3
4# Define the sample size
5sample_size = 25
6
7# Import the data to a pandas DataFrame
8df = pd.read_csv("FILENAME_GOES_HERE.csv")
9
10# ALTERNATIVE: If you use Excel, use this instead. Supports xls, xlsx, xlsm,
11# xlsb, odf, ods and odt file extensions.
12# df = pd.read_excel("FILENAME_GOES_HERE.xlsx")
13
14# Print totals prior to sampling
15print("Dataframe size (rows, columns): ", df.shape)
16
17# Sample
18sample = df.sample(sample_size)
19print("Sample size: ", sample_size)
20print("Sample:\n", sample)
21
22# ALTERNATIVE: Replacement Samples
23#
24# If you want replacement samples (e.g., 10 samples & 3 replacements), you will
25# need to increase sample size to the total you want (e.g., 13). If that is
26# larger than the population, you will need to use the `replace=True` parameter.
27#
28# # Sample Size: 25 + 5 replacement samples
29# sample_size = 30
30# sample = df.sample(30, replace=True)