Skip to main content

A python lib for data generation

Project description

datamaker-faker

Hatch project Ruff License: MIT


Table of Contents

Installation

pip install datamaker-faker

Features

This package:

  • Aims to be a replacement for the faker package in Python but NOT a drop-in replacement.
  • Fast: Generate data quickly at large scales.
  • Reproducible: Set a seed to generate the same data over and over.
  • Relational: Generate data that is related to each other.
  • Extensible: Swop out the data for your own, or bring your own generators.

Usage

import json
from datamaker_faker import Faker

# define your data model
model = {
    "first": "first_name",
    "last": "last_name",
    "sex": "sex",
    "city": "city",
    "country": "country",
}

# create a new faker instance
faker = Faker(model, seed=9)

# generate some fake data
df = faker.generate(10)

# write the data to a csv file
df.to_csv("datafaker.csv")

# or leverage pandas to convert the data to json
data = df.to_dict("records")
print(json.dumps(data, indent=2))
See generated JSON data
[
  {
    "first": "sophia",
    "last": "weber",
    "sex": "female",
    "city": "munich",
    "country": "germany"
  },
  {
    "first": "aiden",
    "last": "brown",
    "sex": "male",
    "city": "toronto",
    "country": "canada"
  },
  {
    "first": "sophia",
    "last": "weber",
    "sex": "female",
    "city": "munich",
    "country": "germany"
  },
  {
    "first": "aaradhya",
    "last": "singh",
    "sex": "female",
    "city": "delhi",
    "country": "india"
  },
  {
    "first": "liam",
    "last": "brown",
    "sex": "male",
    "city": "chicago",
    "country": "united states"
  },
  {
    "first": "daniel",
    "last": "kamau",
    "sex": "male",
    "city": "nairobi",
    "country": "kenya"
  },
  {
    "first": "alexander",
    "last": "smirnov",
    "sex": "male",
    "city": "nizhny novgorod",
    "country": "russia"
  },
  {
    "first": "johann",
    "last": "weber",
    "sex": "male",
    "city": "munich",
    "country": "germany"
  },
  {
    "first": "arjun",
    "last": "singh",
    "sex": "male",
    "city": "delhi",
    "country": "india"
  },
  {
    "first": "leonardo",
    "last": "ferrari",
    "sex": "male",
    "city": "naples",
    "country": "italy"
  }
]

Disclaimer

This package is a work in progress and is not yet ready for production use.

License

datamaker-faker is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

datamaker_faker-0.0.1.tar.gz (12.6 kB view hashes)

Uploaded Source

Built Distribution

datamaker_faker-0.0.1-py3-none-any.whl (12.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page