Last active
June 30, 2020 20:48
-
-
Save takuan-osho/27df2d301ed7b318b08089dd4a4edce7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
from typing import Generator | |
import pandas as pd | |
from faker import Faker | |
def generate_fake_data( | |
func_name: str, | |
data_length: int = 10000, | |
data_types: int = 100, | |
locale: str = "ja_JP", | |
) -> Generator[str, None, None]: | |
""" | |
:func_name: 使用するFakerインスタンスのproviderの名前 | |
:data_length: データ件数 | |
:data_types: データの種類の上限数 | |
:locale: Fakerインスタンスのlocale | |
""" | |
faker = Faker(locale) | |
faker_func = getattr(faker, func_name) | |
faker_types = [faker_func() for _ in range(data_types)] | |
return (faker_types[random.randrange(0, data_types)] for _ in range(data_length)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment