-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsimple_randomization.py
More file actions
36 lines (30 loc) · 1.12 KB
/
simple_randomization.py
File metadata and controls
36 lines (30 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import pandas as pd
import numpy as np
# Set seed for reproducibility
np.random.seed(42)
# Read DMA list
dmas = pd.read_csv("dma_list.csv")
# Simple random assignment without replacement to avoid duplicate groupings
dmas["arm"] = np.random.choice(["Treatment", "Control"],
size=len(dmas),
replace=False)
# Check and print group size balance
group_counts = dmas["arm"].value_counts()
print("Group assignment counts:\n", group_counts)
# Save assignments
dmas.to_csv("geoRCT_assignments.csv", index=False)
import pandas as pd
import numpy as np
# Set seed for reproducibility
np.random.seed(42)
# Read DMA list
dmas = pd.read_csv(“dma_list.csv”)
# Simple random assignment without replacement to avoid duplicate groupings
dmas[“arm”] = np.random.choice([“Treatment”, “Control”],
size=len(dmas),
replace=False)
# Check and print group size balance
group_counts = dmas[“arm”].value_counts()
print(“Group assignment counts:\n”, group_counts)
# Save assignments
dmas.to_csv(“geoRCT_assignments.csv”, index=False)