main

2020/04/13

generate fake or generic data for your data science project

Faker is a Python package that generates fake data for you. Whether you need to bootstrap your database, create good-looking XML documents, fill-in your persistence to stress test it, or anonymize data taken from a production service, Faker is for you.

pip install Faker

https://faker.readthedocs.io/en/master/

quick example


from faker import Faker
fake = Faker()
   fake.name()
   fake.address()
   fake.text()


adding a provider:

from faker import Faker
from faker.providers import internet

fake = Faker()
fake.add_provider(internet)

print(fake.ipv4_private())

adding a localization:

from faker import Faker

fake = Faker('it_IT')for _ in range(10):print(fake.name())# 'Elda Palumbo'# 'Pacifico Giordano'# 'Sig. Avide Guerra'# 'Yago Amato'# 'Eustachio Messina'# 'Dott. Violante Lombardo'# 'Sig. Alighieri Monti'# 'Costanzo Costa'# 'Nazzareno Barbieri'# 'Max Coppola'

US localized field:



No comments:

Post a Comment

How to Supercharge Your Python Classes with Class Methods

  How to Supercharge Your Python Classes with Class Methods | by Siavash Yasini | May, 2024 | Towards Data Science As we just mentioned, a c...