Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # To add a new cell, type '#%%'
- # To add a new markdown cell, type '#%% [markdown]'
- #%%
- import pandas as pd
- import random
- from datetime import datetime
- from dateutil.relativedelta import relativedelta
- from faker import Faker
- import pandas as pd
- #%%
- fake = Faker()
- def get_random_name(taken_names):
- name = '.'.join(fake.sentence().lower()[:-1].split())
- while name in taken_names:
- name = '.'.join(fake.sentence().lower()[:-1].split())
- return name
- ten_years_ago = (datetime.now() - relativedelta(years=10)).timestamp()
- def get_random_dt_after(after = ten_years_ago):
- now = datetime.now().timestamp()
- return datetime.fromtimestamp(random.uniform(after, now))
- #%%
- rows = dict([])
- pk = 1
- for i in range(10000):
- identifier = get_random_name(rows.keys())
- title = ' '.join([word.capitalize() for word in identifier.split('.')])
- description = fake.text()
- published_ts = get_random_dt_after()
- last_updated_ts = get_random_dt_after(after = published_ts.timestamp())
- rows[identifier] = (pk, identifier, title, description, published_ts, last_updated_ts)
- pk = pk + 1
- #%%
- fake = Faker()
- fake.sentence().lower()[:-1]
- #%%
- df = pd.DataFrame(rows.values(), columns =['PK', 'Id', 'Title', 'Description', 'Published_TS', 'Last_Updated_TS'])
- #%%
- df.head()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement