0
# Personal Data Generation
1
2
Generate realistic personal information including names, demographics, contact details, and identification data with proper localization support across 35+ locales.
3
4
## Capabilities
5
6
### Name Generation
7
8
Generate names with locale-appropriate formatting and gender considerations.
9
10
```python { .api }
11
class Person(BaseDataProvider):
12
def full_name(self, gender: Gender = None) -> str:
13
"""
14
Generate a full name (first + last).
15
16
Parameters:
17
- gender (Gender, optional): Specify gender for name selection
18
19
Returns:
20
str: Full name like "John Smith"
21
"""
22
23
def first_name(self, gender: Gender = None) -> str:
24
"""
25
Generate a first name.
26
27
Parameters:
28
- gender (Gender, optional): MALE or FEMALE for gender-specific names
29
30
Returns:
31
str: First name like "John" or "Jane"
32
"""
33
34
def surname(self) -> str:
35
"""
36
Generate a surname/family name.
37
38
Returns:
39
str: Last name like "Smith"
40
"""
41
42
def last_name(self) -> str:
43
"""
44
Alias for surname().
45
46
Returns:
47
str: Last name like "Johnson"
48
"""
49
50
def name(self, gender: Gender = None) -> str:
51
"""
52
Alias for full_name().
53
54
Parameters:
55
- gender (Gender, optional): Specify gender for name selection
56
57
Returns:
58
str: Full name
59
"""
60
61
def title(self, gender: Gender = None, title_type: TitleType = None) -> str:
62
"""
63
Generate a personal title.
64
65
Parameters:
66
- gender (Gender, optional): Gender for title selection
67
- title_type (TitleType, optional): Type of title (TYPICAL, ACADEMIC, etc.)
68
69
Returns:
70
str: Title like "Mr.", "Dr.", "Prof."
71
"""
72
73
def username(self, mask: str = None, drange: tuple[int, int] = (1800, 2100)) -> str:
74
"""
75
Generate a username.
76
77
Parameters:
78
- mask (str, optional): Format mask for username
79
- drange (tuple): Date range for numeric components
80
81
Returns:
82
str: Username like "user123", "john_doe2024"
83
"""
84
```
85
86
### Contact Information
87
88
Generate email addresses, phone numbers, and other contact details.
89
90
```python { .api }
91
class Person(BaseDataProvider):
92
def email(self) -> str:
93
"""
94
Generate an email address.
95
96
Returns:
97
str: Email like "user@example.com"
98
"""
99
100
def phone_number(self, mask: str = "", placeholder: str = "#") -> str:
101
"""
102
Generate a phone number with optional formatting.
103
104
Parameters:
105
- mask (str): Format mask (e.g., "+1-###-###-####")
106
- placeholder (str): Character to replace in mask (default "#")
107
108
Returns:
109
str: Formatted phone number
110
111
Usage:
112
```python
113
person.phone_number() # "555-123-4567"
114
person.phone_number(mask="+1 (###) ###-####") # "+1 (555) 123-4567"
115
```
116
"""
117
118
def telephone(self) -> str:
119
"""
120
Alias for phone_number().
121
122
Returns:
123
str: Phone number
124
"""
125
```
126
127
### Demographics and Physical Attributes
128
129
Generate demographic data and physical characteristics.
130
131
```python { .api }
132
class Person(BaseDataProvider):
133
def birthdate(self, min_year: int = 1980, max_year: int = 2023) -> datetime.date:
134
"""
135
Generate a birth date.
136
137
Parameters:
138
- min_year (int): Minimum birth year
139
- max_year (int): Maximum birth year
140
141
Returns:
142
datetime.date: Birth date
143
"""
144
145
146
def gender(self) -> str:
147
"""
148
Generate a gender.
149
150
Returns:
151
str: Gender like "Male" or "Female"
152
"""
153
154
def gender_symbol(self) -> str:
155
"""
156
Generate a gender symbol.
157
158
Returns:
159
str: Symbol like "♂" or "♀"
160
"""
161
162
def gender_code(self) -> int:
163
"""
164
Generate a gender code.
165
166
Returns:
167
int: 0 for male, 1 for female
168
"""
169
170
def sex(self) -> str:
171
"""
172
Alias for gender().
173
174
Returns:
175
str: Sex/gender
176
"""
177
178
def height(self, minimum: float = 1.5, maximum: float = 2.0) -> str:
179
"""
180
Generate height in meters.
181
182
Parameters:
183
- minimum (float): Minimum height in meters
184
- maximum (float): Maximum height in meters
185
186
Returns:
187
str: Height like "1.75 m"
188
"""
189
190
def weight(self, minimum: int = 38, maximum: int = 90) -> int:
191
"""
192
Generate weight in kilograms.
193
194
Parameters:
195
- minimum (int): Minimum weight in kg
196
- maximum (int): Maximum weight in kg
197
198
Returns:
199
int: Weight in kg
200
"""
201
202
def blood_type(self) -> str:
203
"""
204
Generate a blood type.
205
206
Returns:
207
str: Blood type like "A+", "O-", "AB+"
208
"""
209
```
210
211
### Professional and Educational Information
212
213
Generate career, education, and professional data.
214
215
```python { .api }
216
class Person(BaseDataProvider):
217
def occupation(self) -> str:
218
"""
219
Generate an occupation/job title.
220
221
Returns:
222
str: Job title like "Software Engineer", "Teacher"
223
"""
224
225
def university(self) -> str:
226
"""
227
Generate a university name.
228
229
Returns:
230
str: University name
231
"""
232
233
def academic_degree(self) -> str:
234
"""
235
Generate an academic degree.
236
237
Returns:
238
str: Degree like "Bachelor of Science", "Master of Arts"
239
"""
240
241
def language(self) -> str:
242
"""
243
Generate a language name.
244
245
Returns:
246
str: Language like "English", "Spanish"
247
"""
248
```
249
250
### Personal Views and Characteristics
251
252
Generate personal beliefs, views, and characteristics.
253
254
```python { .api }
255
class Person(BaseDataProvider):
256
def political_views(self) -> str:
257
"""
258
Generate political views.
259
260
Returns:
261
str: Political leaning like "Liberal", "Conservative"
262
"""
263
264
def worldview(self) -> str:
265
"""
266
Generate a worldview/philosophy.
267
268
Returns:
269
str: Worldview like "Humanist", "Pragmatist"
270
"""
271
272
def views_on(self) -> str:
273
"""
274
Generate random views on various topics.
275
276
Returns:
277
str: Views on topics like politics, religion, etc.
278
"""
279
280
def nationality(self, gender: Gender = None) -> str:
281
"""
282
Generate nationality based on locale.
283
284
Parameters:
285
- gender (Gender, optional): Gender for language-specific forms
286
287
Returns:
288
str: Nationality like "American", "German"
289
"""
290
```
291
292
### Identification and Security
293
294
Generate identification numbers, passwords, and security-related data.
295
296
```python { .api }
297
class Person(BaseDataProvider):
298
def identifier(self, mask: str = "##-##/##") -> str:
299
"""
300
Generate an identifier with custom format.
301
302
Parameters:
303
- mask (str): Format mask using # as placeholder
304
305
Returns:
306
str: Formatted identifier
307
308
Usage:
309
```python
310
person.identifier("##-##/##") # "12-34/56"
311
person.identifier("ID-####") # "ID-1234"
312
```
313
"""
314
315
def password(self, length: int = 8, hashed: bool = False) -> str:
316
"""
317
Generate a password.
318
319
Parameters:
320
- length (int): Password length
321
- hashed (bool): Return hashed password if True
322
323
Returns:
324
str: Password or hashed password
325
"""
326
```
327
328
## Usage Examples
329
330
### Basic Personal Data
331
332
```python
333
from mimesis import Person
334
from mimesis.locales import Locale
335
336
person = Person(Locale.EN)
337
338
# Generate complete profile
339
profile = {
340
'name': person.full_name(),
341
'email': person.email(),
342
'phone': person.phone_number(),
343
'age': person.age(),
344
'occupation': person.occupation()
345
}
346
```
347
348
### Localized Names
349
350
```python
351
from mimesis import Person
352
from mimesis.locales import Locale
353
354
# Different locales produce appropriate names
355
person_en = Person(Locale.EN)
356
person_ja = Person(Locale.JA)
357
person_de = Person(Locale.DE)
358
359
english_name = person_en.full_name() # "John Smith"
360
japanese_name = person_ja.full_name() # "田中太郎"
361
german_name = person_de.full_name() # "Hans Müller"
362
```
363
364
### Gender-Specific Data
365
366
```python
367
from mimesis import Person
368
from mimesis.enums import Gender
369
370
person = Person()
371
372
# Generate gender-specific names
373
male_name = person.first_name(gender=Gender.MALE) # "James"
374
female_name = person.first_name(gender=Gender.FEMALE) # "Sarah"
375
376
# Gender-specific nationality (for languages with gender forms)
377
male_nationality = person.nationality(gender=Gender.MALE)
378
female_nationality = person.nationality(gender=Gender.FEMALE)
379
```
380
381
### Formatted Contact Information
382
383
```python
384
from mimesis import Person
385
386
person = Person()
387
388
# Different phone number formats
389
us_phone = person.phone_number(mask="+1 (###) ###-####") # "+1 (555) 123-4567"
390
intl_phone = person.phone_number(mask="+##-##-###-####") # "+12-34-567-8901"
391
392
# Custom identifiers
393
ssn = person.identifier(mask="###-##-####") # "123-45-6789"
394
employee_id = person.identifier(mask="EMP-####") # "EMP-1234"
395
```
396
397
### Complete User Profile
398
399
```python
400
from mimesis import Person
401
from mimesis.enums import Gender
402
403
person = Person(Locale.EN)
404
405
def generate_user_profile():
406
gender = person.gender()
407
return {
408
'personal': {
409
'name': person.full_name(),
410
'gender': gender,
411
'age': person.age(minimum=18, maximum=65),
412
'birthdate': person.birthdate(min_year=1960, max_year=2005),
413
'nationality': person.nationality(),
414
},
415
'contact': {
416
'email': person.email(),
417
'phone': person.phone_number(mask="+1-###-###-####"),
418
},
419
'physical': {
420
'height': person.height(),
421
'weight': person.weight(),
422
'blood_type': person.blood_type(),
423
},
424
'professional': {
425
'occupation': person.occupation(),
426
'university': person.university(),
427
'degree': person.academic_degree(),
428
},
429
'personal_views': {
430
'political': person.political_views(),
431
'worldview': person.worldview(),
432
}
433
}
434
435
profile = generate_user_profile()
436
```