README.md
Project description
Concepts
Generators: Generators are the mechanism by which a Field actually gets populated with data.
There are different types of generators (see generators.py). Each
generator is a class and has a method to validate parameters passed to the generator, a method
to generate a single value, and then a method that gets called in
core.py which combines the other two methods, the parameters, and the
associated Table's row_count to generate all the requested values.
Field: A Field represents a single column in a Table. A Field is instantiated based on a
FieldConfig found in models.py, which includes a name, and
params which will be passed to the generator associated with that Field.
Table: A Table is a collection of Fields. Defined in models.py, each Table
is instantiated based on a TableConfig and includes a name and a row_count. The row_count
will be passed to the populate() method of each Field associated with a Table, and in turn to
the generate() method of each generator associated with each Field.
A Table is stored in a Polars DataFrame.
Usage
from fable import Table, Field
from fable.models import TableConfig, FieldConfig
import fable.generators as fg
# Define a TableConfig
users_table_config = TableConfig(name="users", row_count=1000)
# Define some FieldConfigs
score_conf = FieldConfig(
name="score",
dtype=int,
generator=fg.NumericGenerator,
params={"lower_bound": 350, "upper_bound": 850},
)
name_conf = FieldConfig(
name="name",
dtype=str,
generator=fg.StringGenerator,
)
birthday_conf = FieldConfig(
name="birthday",
dtype=str,
generator=fg.DateGenerator,
)
# Instantiate a table using our TableConfig
users_table = Table(users_table_config)
# Instantiate some fields using our field config
score = Field(score_conf)
name = Field(name_conf)
birthday = Field(birthday_conf)
# Add the Fields to the Table
example_table.add_fields(field_list)
# Add some data to the Table
example_table.populate()
# Inspect the data in the Table
example_table.head()
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 fabledata-0.0.2.tar.gz.
File metadata
- Download URL: fabledata-0.0.2.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25019dd4950bebc87bf90e7cd4c8c62dfa53331c262f8a3b2a10dcdacdadc106
|
|
| MD5 |
3cef49f2368ba0e201eb7522efb7d4d1
|
|
| BLAKE2b-256 |
7716284077c25b3b8ad418b1748095a4cecf3bb9ee3612c42e55a2e2befa34e6
|
File details
Details for the file fabledata-0.0.2-py3-none-any.whl.
File metadata
- Download URL: fabledata-0.0.2-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d64f3e236792b22c237870997ca8eec43ac6f62fc35e82ff89bb38dd896965bb
|
|
| MD5 |
f5e644142993cc7aaf5e7ff2acadf6b7
|
|
| BLAKE2b-256 |
3a17584c022653df41a006626b5a5f0f51d72c1e2eadb99c56eb98d9c228e055
|