-
Notifications
You must be signed in to change notification settings - Fork 4
Custom Rules
Ravi Kiran Pagidi edited this page Jun 28, 2026
·
1 revision
Use custom_rules when a column's business meaning or valid range cannot be inferred reliably from its name and type.
from great_generator import generate_from_schema
schema = {
"customer_id": "string",
"customer_name": "string",
"age": "int",
"salary": "double",
"status": "string",
"created_at": "datetime",
"campaign_code": "string",
}
df = generate_from_schema(
schema,
rows=5000,
custom_rules={
"customer_id": {"prefix": "CUST"},
"customer_name": {"type": "full_name"},
"age": {"min": 25, "max": 65},
"salary": {"min": 60000, "max": 180000},
"status": {"weighted_values": {"Active": 0.8, "Inactive": 0.2}},
"created_at": {"start": "2023-01-01", "end": "2024-12-31"},
"campaign_code": {"pattern": "CMP-{index:06d}"},
},
)| Key | Purpose |
|---|---|
type |
Semantic override |
min, max
|
Numeric or age bounds |
values |
Allowed categories |
weighted_values |
Weighted categorical output |
prefix |
ID prefix |
pattern |
Format string with {index}
|
start, end
|
Date window |
null_rate |
Null rate for non-ID fields |
unique |
Validation expectation; IDs are unique by default |
Inline rich schema metadata is planned. Today, keep the dtype schema and custom rules separate.