im trying to create a data set with a unique id code but i get a
'ValueError not enough values to unpack (expected 6, got 5)'
on line 8, basically, I am trying to:
- generate a unique 6 digit id code
- append dataset value with 'ID' ex: ID123456
UPDATE: fixed the error and ID append, now how do i make sure the generated id is unique in the dataset?
from faker import Faker
import random
import pandas as pd
Faker.seed(0)
random.seed(0)
fake = Faker("en_US")
fixed_digits = 6
concatid = 'ID'
idcode,name, city, country, job, age = [[] for k in range(0,6)]
for row in range(0,100):
idcode.append(concatid + str(random.randrange(111111, 999999, fixed_digits)))
name.append(fake.name())
city.append(fake.city())
country.append(fake.country())
job.append(fake.job())
age.append(random.randint(20,100))
d = {"ID Code":idcode, "Name":name, "Age":age, "City":city, "Country":country, "Job":job}
df = pd.DataFrame(d)
df.head()
planning to generate 1k rows