faker
libraryIn basic terms, the faker
library generates fake data. This library can be used to create fake email IDs, profile information, and so on.
We use pip
to install faker
:
pip install faker
The faker
module contains different functions to generate dummy data. It delegates the task of data generation to providers. Each provider is used to generate specific dummy data.
One such provider is profile
. The profile
provider is a collection of functions to generate personal profiles and identities.
simple_profile()
methodThe simple_profile()
method of the profile
provider is used to generate a basic profile with personal information.
The attributes of the profile generated are as follows:
simple_profile(sex: Optional[GenderType] = None) → Dict[str, Union[str, datetime.date, GenderType]]
sex
: This is the sex of the profile to be generated. This is an optional argument. The character M
is used to indicate male, and F
is used to indicate female.Refer to Standard Providers to get the standard providers in the
faker
module.
import fakerfaker_obj = faker.Faker()gender = 'M'male_profile = faker_obj.simple_profile(sex=gender)print("Male profile generated is as follows:\n", male_profile)gender = 'F'male_profile = faker_obj.simple_profile(sex=gender)print("Female profile generated is as follows:\n", male_profile)
faker
module.faker
class.simple_profile()
method with the sex argument as M
.simple_profile()
method with the sex argument as F
.