Skip to main content

rand-engine

Synthetic data, very fast, from a declarative spec — for batch and streaming, on any platform.

  • Sink-agnostic: feed Kafka and other queues, data lakes and object storage, files, databases or Spark.
  • NumPy-fast: the core is Python + NumPy (DataGenerator); Spark is supported (SparkGenerator), never required.
  • Faker composes on top: build a small realistic pool with Faker, sample millions of rows from it at NumPy speed.
  • Related tables: pk and fk columns keep keys consistent across tables, batches, streams and files.

Install

pip install rand-engine

Quickstart

A spec maps each column to a method and its kwargs.

from rand_engine import DataGenerator

spec = {
    "user_id": {"method": "int_zfilled", "kwargs": {"length": 8}},
    "age": {"method": "integers", "kwargs": {"min": 18, "max": 80}},
    "plan": {"method": "distincts_prop", "kwargs": {"distincts": {"free": 8, "pro": 2}}},
    "signup": {"method": "dates", "kwargs": {"start": "2024-01-01", "end": "2024-12-31"}},
}

df = DataGenerator(spec, seed=42).size(1_000).get_df()
assert df.shape == (1_000, 4) and df["age"].between(18, 80).all()

Seeded reproducibility

The seed is per generator: each DataGenerator owns its own NumPy Generator (PCG64), so the caller's NumPy global state is never read or reset. The same spec, seed and size give the same frame. Values differ from 0.6.x, which drew from the global NumPy seed.

import numpy as np

np.random.seed(0)
state = np.random.get_state()[1].copy()
a = DataGenerator(spec, seed=7).size(100).get_df()
b = DataGenerator(spec, seed=7).size(100).get_df()
assert a.equals(b)
assert (np.random.get_state()[1] == state).all()

Faker pools at scale

Install the optional Faker dependency with pip install faker before running this example. Faker is slow per value; draw a pool once and let rand-engine sample it.

from faker import Faker

fake = Faker()
Faker.seed(0)
names = [fake.name() for _ in range(200)]

people = DataGenerator({"name": {"method": "distincts", "kwargs": {"distincts": names}}}, seed=1).size(10_000).get_df()
assert people["name"].isin(names).all()

Give the child's fk the parent's pk spec and size: every child key exists in the parent.

customer_pk = {"method": "pk", "kwargs": {"start": 1, "format": "C{:05d}"}}

customers = DataGenerator({"customer_id": customer_pk}, seed=1).size(500).get_df()
orders = DataGenerator({
    "order_id": {"method": "pk", "kwargs": {"start": 1}},
    "customer_id": {"method": "fk", "kwargs": {"parent": customer_pk, "parent_size": 500}},
}, seed=2).size(2_000).get_df()

assert customers["customer_id"].is_unique
assert set(orders["customer_id"]) <= set(customers["customer_id"])

Streams and files

stream_dict yields records forever at a bounded rate; write writes csv, json or parquet.

from itertools import islice
import pandas as pd

events = DataGenerator({"event_id": {"method": "pk", "kwargs": {"start": 1}}}, seed=1).size(10)
records = list(islice(events.stream_dict(min_throughput=500, max_throughput=1000), 5))
assert [r["event_id"] for r in records] == [1, 2, 3, 4, 5]

orders_gen = DataGenerator({"order_id": {"method": "pk", "kwargs": {"start": 1}}}, seed=1).size(1_000)
orders_gen.write.format("parquet").save("out/orders.parquet")
assert len(pd.read_parquet("out/orders.parquet")) == 1_000

Learn more

Metadata

Release files for rand-engine 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rand-engine 0.7.0
File Size Uploaded
rand_engine-0.7.0.tar.gz 42.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rand-engine 0.7.0
File Interpreter ABI Platform
rand_engine-0.7.0-py3-none-any.whl Python 3 none any Details

Total release size: 94.4 kB

Release files / rand_engine-0.7.0.tar.gz

Download URL rand_engine-0.7.0.tar.gz
Size 42.7 kB
Tags Source
SHA-256 checksum
How to use checksums
0c12762e01a2fcf7ec709b0de4ce0074a6cdb014b91b41d5e0e290652dbcee7d
BLAKE2b-256 checksum
How to use checksums
2ef92261f2fd1fdada9308867b80bf8fcb3032d54534cf3d12c7bf76cd7478a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release files / rand_engine-0.7.0-py3-none-any.whl

Download URL rand_engine-0.7.0-py3-none-any.whl
Size 51.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
91c1ac53c3b1c6fef97db665366fe3d3133baf6007e1b9c244ab8b009847f192
BLAKE2b-256 checksum
How to use checksums
6c4417c8608447e2feb4e79d54024ca5a77d0e87a64db36eb1c26787514ae520
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 14, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.7.0 This release

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.5

2 release files

0.5.3

2 release files

0.4.7

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.14

2 release files

0.3.13

2 release files

0.3.12

2 release files

0.3.11

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.5

2 release files

0.3.3

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.0.3

1 release file

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page