.. contents:: **tblfaker**
:backlinks: top
:depth: 2
Summary
============================================
tblfaker is a Python library to generate fake tabular data.
.. image:: https://badge.fury.io/py/tblfaker.svg
:target: https://badge.fury.io/py/tblfaker
:alt: PyPI package version
.. image:: https://img.shields.io/pypi/pyversions/tblfaker.svg
:target: https://pypi.org/project/tblfaker
:alt: Supported Python versions
.. image:: https://github.com/thombashi/tblfaker/actions/workflows/ci.yml/badge.svg
:target: https://github.com/thombashi/tblfaker/actions/workflows/ci.yml
:alt: CI status of Linux/macOS/Windows
.. image:: https://coveralls.io/repos/github/thombashi/tblfaker/badge.svg?branch=master
:target: https://coveralls.io/github/thombashi/tblfaker?branch=master
:alt: Test coverage
.. image:: https://github.com/thombashi/tblfaker/actions/workflows/github-code-scanning/codeql/badge.svg
:target: https://github.com/thombashi/tblfaker/actions/workflows/github-code-scanning/codeql
:alt: CodeQL
Installation
============================================
::
pip install tblfaker
Install all the extra dependencies:
::
pip install tblfaker[all]
Usage
============================================
Basic Usage
--------------------------------------------
Generate tabular data at random
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:Sample Code:
.. code-block:: python
from tblfaker import TableFaker
faker = TableFaker()
print("[1]")
for row in faker.generate(["name", "address"], rows=4).as_tuple():
print(row)
print("\n[2]")
for row in faker.generate(["name", "address"], rows=4).as_tuple():
print(row)
:Output:
.. code-block::
[1]
Row(name='Jonathan Hendrix', address='368 Melanie Inlet Suite 890\nLake Stephanie, MT 17441')
Row(name='Kristina Simmons', address='3867 Perry Alley Suite 957\nLindafurt, FL 12507')
Row(name='Rebecca Velasquez', address='107 Karla Forges Apt. 925\nEast Jonathan, NC 85462')
Row(name='Jordan Morris', address='6341 Jessica Walks\nReynoldsshire, MD 05131')
[2]
Row(name='Caitlin Bush', address='87380 Barbara Haven Suite 042\nHutchinsonburgh, IA 39544')
Row(name='Jennifer King', address='39729 Gray Inlet Apt. 693\nPort Peter, AL 80733')
Row(name='Stephanie Smith', address='256 Emily Street\nCooperhaven, MS 70299')
Row(name='Nicholas Miller', address='59845 Daniel Ford Suite 729\nDamontown, UT 19811
Reproduce the same tabular data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fake tabular data can reproduce by passing the same ``seed`` value to ``TableFaker`` constructor.
:Sample Code:
.. code-block:: python
from tblfaker import TableFaker
seed = 1
print("[1]")
faker = TableFaker(seed=seed)
for row in faker.generate(["name", "address"], rows=4).as_tuple():
print(row)
print("\n[2]")
faker = TableFaker(seed=seed)
for row in faker.generate(["name", "address"], rows=4).as_tuple():
print(row)
:Output:
.. code-block::
[1]
Row(name='Ryan Gallagher', address='6317 Mary Light\nSmithview, HI 13900')
Row(name='Amanda Johnson', address='3608 Samuel Mews Apt. 337\nHousebury, WA 13608')
Row(name='Willie Heath', address='868 Santiago Grove\nNicolehaven, NJ 05026')
Row(name='Dr. Jared Ortega', address='517 Rodriguez Divide Suite 570\nWest Melinda, NH 85325')
[2]
Row(name='Ryan Gallagher', address='6317 Mary Light\nSmithview, HI 13900')
Row(name='Amanda Johnson', address='3608 Samuel Mews Apt. 337\nHousebury, WA 13608')
Row(name='Willie Heath', address='868 Santiago Grove\nNicolehaven, NJ 05026')
Row(name='Dr. Jared Ortega', address='517 Rodriguez Divide Suite 570\nWest Melinda, NH 85325')
Set locale for fake data
--------------------------------------------
:Sample Code:
.. code-block:: python
from tblfaker import TableFaker
faker = TableFaker(locale="ja_JP")
for row in faker.generate(["name", "address"], rows=4).as_tuple():
print(row)
:Output:
.. code-block::
Row(name='工藤 健一', address='宮崎県武蔵村山市六番町19丁目15番11号')
Row(name='井上 聡太郎', address='愛媛県長生郡白子町豊町33丁目7番20号 戸島コート620')
Row(name='大垣 美加子', address='京都府山武郡芝山町三ノ輪34丁目15番8号 クレスト所野560')
Row(name='宇野 くみ子', address='宮城県八街市西浅草20丁目24番6号')
Generate data in other data formats
--------------------------------------------
Generate data in dict
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:Sample Code:
.. code-block:: python
from tblfaker import TableFaker
import json
faker = TableFaker(seed=1)
print(json.dumps(faker.generate(["name", "address"], rows=2, table_name="dict").as_dict(), indent=4))
:Output:
.. code-block:: json
{
"dict": [
{
"name": "Ryan Gallagher",
"address": "6317 Mary Light\nSmithview, HI 13900"
},
{
"name": "Amanda Johnson",
"address": "3608 Samuel Mews Apt. 337\nHousebury, WA 13608"
}
]
}
Generate data in pandas.DataFrame
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
:Sample Code:
.. code-block:: python
from tblfaker import TableFaker
faker = TableFaker(seed=seed)
print(faker.generate(["name", "address"], rows=4).as_dataframe())
:Output:
.. code-block::
name address
0 Ryan Gallagher 6317 Mary Light\nSmithview, HI 13900
1 Amanda Johnson 3608 Samuel Mews Apt. 337\nHousebury, WA 13608
2 Willie Heath 868 Santiago Grove\nNicolehaven, NJ 05026
3 Dr. Jared Ortega 517 Rodriguez Divide Suite 570\nWest Melinda, ...
Dependencies
============================================
- Python 3.8+
- `Python package dependencies (automatically installed) <https://github.com/thombashi/tblfaker/network/dependencies>`__
Raw data
{
"_id": null,
"home_page": "https://github.com/thombashi/tblfaker",
"name": "tblfaker",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "table,faker",
"author": "Tsuyoshi Hombashi",
"author_email": "tsuyoshi.hombashi@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/f5/06/e4de573f632f7f49db2f26d9154d646e4db52372767ae4ca535b03813859/tblfaker-1.0.0.tar.gz",
"platform": null,
"description": ".. contents:: **tblfaker**\n :backlinks: top\n :depth: 2\n\n\nSummary\n============================================\ntblfaker is a Python library to generate fake tabular data.\n\n.. image:: https://badge.fury.io/py/tblfaker.svg\n :target: https://badge.fury.io/py/tblfaker\n :alt: PyPI package version\n\n.. image:: https://img.shields.io/pypi/pyversions/tblfaker.svg\n :target: https://pypi.org/project/tblfaker\n :alt: Supported Python versions\n\n.. image:: https://github.com/thombashi/tblfaker/actions/workflows/ci.yml/badge.svg\n :target: https://github.com/thombashi/tblfaker/actions/workflows/ci.yml\n :alt: CI status of Linux/macOS/Windows\n\n.. image:: https://coveralls.io/repos/github/thombashi/tblfaker/badge.svg?branch=master\n :target: https://coveralls.io/github/thombashi/tblfaker?branch=master\n :alt: Test coverage\n\n.. image:: https://github.com/thombashi/tblfaker/actions/workflows/github-code-scanning/codeql/badge.svg\n :target: https://github.com/thombashi/tblfaker/actions/workflows/github-code-scanning/codeql\n :alt: CodeQL\n\n\nInstallation\n============================================\n::\n\n pip install tblfaker\n\n\nInstall all the extra dependencies:\n\n::\n\n pip install tblfaker[all]\n\n\nUsage\n============================================\n\nBasic Usage\n--------------------------------------------\n\nGenerate tabular data at random\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n:Sample Code:\n .. code-block:: python\n\n from tblfaker import TableFaker\n\n faker = TableFaker()\n\n print(\"[1]\")\n for row in faker.generate([\"name\", \"address\"], rows=4).as_tuple():\n print(row)\n\n print(\"\\n[2]\")\n for row in faker.generate([\"name\", \"address\"], rows=4).as_tuple():\n print(row)\n\n:Output:\n .. code-block::\n\n [1]\n Row(name='Jonathan Hendrix', address='368 Melanie Inlet Suite 890\\nLake Stephanie, MT 17441')\n Row(name='Kristina Simmons', address='3867 Perry Alley Suite 957\\nLindafurt, FL 12507')\n Row(name='Rebecca Velasquez', address='107 Karla Forges Apt. 925\\nEast Jonathan, NC 85462')\n Row(name='Jordan Morris', address='6341 Jessica Walks\\nReynoldsshire, MD 05131')\n\n [2]\n Row(name='Caitlin Bush', address='87380 Barbara Haven Suite 042\\nHutchinsonburgh, IA 39544')\n Row(name='Jennifer King', address='39729 Gray Inlet Apt. 693\\nPort Peter, AL 80733')\n Row(name='Stephanie Smith', address='256 Emily Street\\nCooperhaven, MS 70299')\n Row(name='Nicholas Miller', address='59845 Daniel Ford Suite 729\\nDamontown, UT 19811\n\n\nReproduce the same tabular data\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nFake tabular data can reproduce by passing the same ``seed`` value to ``TableFaker`` constructor.\n\n:Sample Code:\n .. code-block:: python\n\n from tblfaker import TableFaker\n\n seed = 1\n\n print(\"[1]\")\n faker = TableFaker(seed=seed)\n for row in faker.generate([\"name\", \"address\"], rows=4).as_tuple():\n print(row)\n\n print(\"\\n[2]\")\n faker = TableFaker(seed=seed)\n for row in faker.generate([\"name\", \"address\"], rows=4).as_tuple():\n print(row)\n\n:Output:\n .. code-block::\n\n [1]\n Row(name='Ryan Gallagher', address='6317 Mary Light\\nSmithview, HI 13900')\n Row(name='Amanda Johnson', address='3608 Samuel Mews Apt. 337\\nHousebury, WA 13608')\n Row(name='Willie Heath', address='868 Santiago Grove\\nNicolehaven, NJ 05026')\n Row(name='Dr. Jared Ortega', address='517 Rodriguez Divide Suite 570\\nWest Melinda, NH 85325')\n\n [2]\n Row(name='Ryan Gallagher', address='6317 Mary Light\\nSmithview, HI 13900')\n Row(name='Amanda Johnson', address='3608 Samuel Mews Apt. 337\\nHousebury, WA 13608')\n Row(name='Willie Heath', address='868 Santiago Grove\\nNicolehaven, NJ 05026')\n Row(name='Dr. Jared Ortega', address='517 Rodriguez Divide Suite 570\\nWest Melinda, NH 85325')\n\n\nSet locale for fake data\n--------------------------------------------\n:Sample Code:\n .. code-block:: python\n\n from tblfaker import TableFaker\n\n faker = TableFaker(locale=\"ja_JP\")\n\n for row in faker.generate([\"name\", \"address\"], rows=4).as_tuple():\n print(row)\n\n:Output:\n .. code-block::\n\n Row(name='\u5de5\u85e4 \u5065\u4e00', address='\u5bae\u5d0e\u770c\u6b66\u8535\u6751\u5c71\u5e02\u516d\u756a\u753a19\u4e01\u76ee15\u756a11\u53f7')\n Row(name='\u4e95\u4e0a \u8061\u592a\u90ce', address='\u611b\u5a9b\u770c\u9577\u751f\u90e1\u767d\u5b50\u753a\u8c4a\u753a33\u4e01\u76ee7\u756a20\u53f7 \u6238\u5cf6\u30b3\u30fc\u30c8620')\n Row(name='\u5927\u57a3 \u7f8e\u52a0\u5b50', address='\u4eac\u90fd\u5e9c\u5c71\u6b66\u90e1\u829d\u5c71\u753a\u4e09\u30ce\u8f2a34\u4e01\u76ee15\u756a8\u53f7 \u30af\u30ec\u30b9\u30c8\u6240\u91ce560')\n Row(name='\u5b87\u91ce \u304f\u307f\u5b50', address='\u5bae\u57ce\u770c\u516b\u8857\u5e02\u897f\u6d45\u834920\u4e01\u76ee24\u756a6\u53f7')\n\n\nGenerate data in other data formats\n--------------------------------------------\n\nGenerate data in dict\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n:Sample Code:\n .. code-block:: python\n\n from tblfaker import TableFaker\n import json\n\n faker = TableFaker(seed=1)\n\n print(json.dumps(faker.generate([\"name\", \"address\"], rows=2, table_name=\"dict\").as_dict(), indent=4))\n\n:Output:\n .. code-block:: json\n\n {\n \"dict\": [\n {\n \"name\": \"Ryan Gallagher\",\n \"address\": \"6317 Mary Light\\nSmithview, HI 13900\"\n },\n {\n \"name\": \"Amanda Johnson\",\n \"address\": \"3608 Samuel Mews Apt. 337\\nHousebury, WA 13608\"\n }\n ]\n }\n\nGenerate data in pandas.DataFrame\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n:Sample Code:\n .. code-block:: python\n\n from tblfaker import TableFaker\n\n faker = TableFaker(seed=seed)\n\n print(faker.generate([\"name\", \"address\"], rows=4).as_dataframe())\n\n:Output:\n .. code-block::\n\n name address\n 0 Ryan Gallagher 6317 Mary Light\\nSmithview, HI 13900\n 1 Amanda Johnson 3608 Samuel Mews Apt. 337\\nHousebury, WA 13608\n 2 Willie Heath 868 Santiago Grove\\nNicolehaven, NJ 05026\n 3 Dr. Jared Ortega 517 Rodriguez Divide Suite 570\\nWest Melinda, ...\n\n\nDependencies\n============================================\n- Python 3.8+\n- `Python package dependencies (automatically installed) <https://github.com/thombashi/tblfaker/network/dependencies>`__\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "tblfaker is a Python library to generate fake tabular data.",
"version": "1.0.0",
"project_urls": {
"Homepage": "https://github.com/thombashi/tblfaker",
"Source": "https://github.com/thombashi/tblfaker",
"Tracker": "https://github.com/thombashi/tblfaker/issues"
},
"split_keywords": [
"table",
"faker"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f123e9b2bfc8ee65cec82e2783d2d5202d1198e9932eb84a81d11d63663ca011",
"md5": "8607d221d5e875694095e32d10934a16",
"sha256": "00664ddade05f64c62ce85c1b23b5ff4ebb6fba74f07396993cdc78ba4214204"
},
"downloads": -1,
"filename": "tblfaker-1.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "8607d221d5e875694095e32d10934a16",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 6785,
"upload_time": "2023-10-07T09:03:04",
"upload_time_iso_8601": "2023-10-07T09:03:04.313329Z",
"url": "https://files.pythonhosted.org/packages/f1/23/e9b2bfc8ee65cec82e2783d2d5202d1198e9932eb84a81d11d63663ca011/tblfaker-1.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f506e4de573f632f7f49db2f26d9154d646e4db52372767ae4ca535b03813859",
"md5": "0d2d2c86d057a7fb646c08d96b9a79be",
"sha256": "424adf4c946cfc4630666de3e8ae392855a78e567d50518edd72de34783f144a"
},
"downloads": -1,
"filename": "tblfaker-1.0.0.tar.gz",
"has_sig": false,
"md5_digest": "0d2d2c86d057a7fb646c08d96b9a79be",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 12568,
"upload_time": "2023-10-07T09:03:06",
"upload_time_iso_8601": "2023-10-07T09:03:06.240702Z",
"url": "https://files.pythonhosted.org/packages/f5/06/e4de573f632f7f49db2f26d9154d646e4db52372767ae4ca535b03813859/tblfaker-1.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-07 09:03:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "thombashi",
"github_project": "tblfaker",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "tblfaker"
}