Deterministic test DataFrame builder with optional PySpark export
Project description
dfgenerator
Lightweight helpers to build deterministic test datasets for Pandas and PySpark, with Faker-powered generators, YAML-based reusable configs, and JSON Schema support.
Features
- 🎲 Deterministic data generation with seed support for reproducible tests
- 📊 Multiple input formats: YAML configs, JSON Schema, Spark/Iceberg DataFrames, or programmatic Python API
- 🌍 Multi-locale support with Faker integration (50+ locales)
- 🔗 Relational data with primary/foreign key support for joinable datasets
- 📤 Multiple export formats: CSV, JSON, Pandas DataFrame, PySpark DataFrame
- 🎯 Smart inference from JSON Schema formats, property names, and existing Spark DataFrames
- ⚡ Spark/Iceberg support - Generate test data from production schemas
- 🚀 CLI and Python API for flexible usage
Quick Start
From Spark/Iceberg DataFrame
from pyspark.sql import SparkSession
from dfgenerator import build_from_spark
# Load production Iceberg table
spark = SparkSession.builder.getOrCreate()
prod_df = spark.read.format("iceberg").load("prod.users")
# Generate test data with same schema
test_data = build_from_spark(prod_df, rows=100, seed=42)
# Export for testing
test_data.to_file("test_users.csv")
test_df = test_data.to_spark(spark)
From JSON Schema
# Generate data from a JSON Schema file
dfgenerator --schema user.schema.json --rows 100 --seed 42 --output users.csv
from dfgenerator import build_from_jsonschema
schema = {
"type": "object",
"properties": {
"id": {"type": "integer"},
"email": {"type": "string", "format": "email"},
"age": {"type": "integer", "minimum": 18, "maximum": 65}
}
}
dataset = build_from_jsonschema(schema, rows=100, seed=42)
dataset.to_file("users.csv")
From YAML Config
dfgenerator --config people.yaml --rows 50 --output people.json
Programmatic API
from dfgenerator import DataFrameBuilder, RowTemplate, ColumnSpec, sequence, choices
template = RowTemplate([
ColumnSpec("id", sequence(1)),
ColumnSpec("city", choices(["Paris", "Berlin", "Boston"])),
])
dataset = DataFrameBuilder().from_template(template, 10).build()
df = dataset.to_pandas()
Architecture
dfgenerator uses a lightweight adapter pattern for extensibility:
- Core Domain: Pure business logic for data generation
- Input Adapters: YAML, JSON Schema, Spark DataFrames (easily extensible!)
- Output Adapters: CSV, JSON, Pandas, PySpark
Want to add support for Protobuf, Avro, or GraphQL schemas? Just create a new adapter!
See docs/ARCHITECTURE.md for details.
Documentation
- User Guide - Complete documentation and examples
- Architecture - Design patterns and extensibility guide
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dfgenerator-0.1.0.tar.gz.
File metadata
- Download URL: dfgenerator-0.1.0.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf80b3a6bff4ed2289e0b36ab0483a5a55b343ca10062ff1d2ebcca9fda8660d
|
|
| MD5 |
f3e78a8a0b076d0e2368a7e9ba9ddc4b
|
|
| BLAKE2b-256 |
af4aa3423e513c4482e9a4b17cc85d54fbc3aeac0635f6cafefb107fab9d83e0
|
Provenance
The following attestation bundles were made for dfgenerator-0.1.0.tar.gz:
Publisher:
deploy.yml on cdahirel/dfgenerator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dfgenerator-0.1.0.tar.gz -
Subject digest:
bf80b3a6bff4ed2289e0b36ab0483a5a55b343ca10062ff1d2ebcca9fda8660d - Sigstore transparency entry: 854332212
- Sigstore integration time:
-
Permalink:
cdahirel/dfgenerator@5f6640f31c9e3a65e308ad1bed6160cfce240f34 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/cdahirel
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@5f6640f31c9e3a65e308ad1bed6160cfce240f34 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file dfgenerator-0.1.0-py3-none-any.whl.
File metadata
- Download URL: dfgenerator-0.1.0-py3-none-any.whl
- Upload date:
- Size: 28.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa6fa74dfa9cea6da01cebf704b0936ff726bab501c675c798e5cde9ddadc20a
|
|
| MD5 |
73122e8a6a22103dec3caff5b022af85
|
|
| BLAKE2b-256 |
dba2887cee3525c9c4ea1ab804b2b285eb484d30bfd5823ed1e610d83dc71bff
|
Provenance
The following attestation bundles were made for dfgenerator-0.1.0-py3-none-any.whl:
Publisher:
deploy.yml on cdahirel/dfgenerator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dfgenerator-0.1.0-py3-none-any.whl -
Subject digest:
aa6fa74dfa9cea6da01cebf704b0936ff726bab501c675c798e5cde9ddadc20a - Sigstore transparency entry: 854332218
- Sigstore integration time:
-
Permalink:
cdahirel/dfgenerator@5f6640f31c9e3a65e308ad1bed6160cfce240f34 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/cdahirel
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
deploy.yml@5f6640f31c9e3a65e308ad1bed6160cfce240f34 -
Trigger Event:
workflow_dispatch
-
Statement type: