Skip to content
Snippets Groups Projects
Commit f59783cb authored by Colbry, Dirk's avatar Colbry, Dirk
Browse files

Adding in Mimesis data generator

parent 4bb22753
No related branches found
No related tags found
No related merge requests found
%% Cell type:markdown id:6600a76c tags:
# Installing required packages
%% Cell type:code id:ae65adaf tags:
``` python
!pip install -r ../requirements.txt
```
%% Cell type:markdown id:d9395405 tags:
# Quickstart Guide to Mimesis
%% Cell type:markdown id:85dd7d12 tags:
## Generating Some Data
Now, let's generate some data using Mimesis! We will use the **Person** provider class from Mimesis to generate a simple table containing a set of Names, Ages, Genders, Academic Degrees, and Occupations and convert the data into a Pandas DataFrame.
%% Cell type:code id:4c184360 tags:
``` python
from mimesis import Person
from mimesis.locales import Locale
from mimesis.enums import Gender
import pandas as pd
```
%% Cell type:code id:3d762ee0 tags:
``` python
person = Person(Locale.EN)
data_list = [{
"Name": person.full_name(),
"Age": person.age(),
"Gender": person.gender(),
"Academic Degree": person.academic_degree(),
"Occupation": person.occupation(),
} for _ in range(100)]
df = pd.DataFrame(data_list)
```
%% Cell type:markdown id:ab22c620 tags:
We will then view the first five rows of our generated data.
%% Cell type:code id:e5d118b2 tags:
``` python
df.head()
```
%% Output
Name Age Gender Academic Degree Occupation
0 Jessenia Roy 31 Female PhD Maintenance Fitter
1 Jasper Schultz 21 Other Bachelor Racehorse Groom
2 Micki Newton 41 Other Bachelor Foundry Worker
3 Doreatha Adams 39 Fluid Master Kitchen Worker
4 Milton Ford 41 Male Bachelor Bank Messenger
%% Cell type:markdown id:d46fda7f tags:
This is just a small preview of what Mimesis can do in terms of data generation. If you want a more detailed guide, you can follow the very detailed instructions at:
https://mimesis.name/en/master/getting_started.html
%% Cell type:markdown id:b9a289e0 tags:
# Quick Start Guide to Faker
%% Cell type:markdown id:f309c13f tags:
### Set Up
%% Cell type:code id:cafac6cb tags:
``` python
from faker import Faker
import pandas as pd
fake = Faker()
Faker.seed(0)
```
%% Cell type:markdown id:bccf7509 tags:
### Generating Data
%% Cell type:code id:ad9390db tags:
``` python
while True:
try:
df = pd.DataFrame(fake.profile())
except ValueError:
continue
break
df.head()
```
%% Output
job company ssn \
0 Hydrogeologist Gomez, Wright and Chen 653-68-0948
1 Hydrogeologist Gomez, Wright and Chen 653-68-0948
residence current_location blood_group \
0 5735 Farley Course\nPort Daniel, OH 79871 -48.693466 O+
1 5735 Farley Course\nPort Daniel, OH 79871 59.532676 O+
website username name sex \
0 https://wright.com/ robinsondanny Michael Montgomery M
1 http://welch-miller.com/ robinsondanny Michael Montgomery M
address mail birthdate
0 Unit 4892 Box 6717\nDPO AE 71770 bramirez@gmail.com 1943-01-04
1 Unit 4892 Box 6717\nDPO AE 71770 bramirez@gmail.com 1943-01-04
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment