def fill_persondata(): db = MySQLdb.connect(host=config.DB_HOST, user=config.DB_USER, passwd=config.DB_PASSWORD, db=config.DB_NAME) cursor = db.cursor() # Zero client, anon cursor.execute( """INSERT INTO PersonData (first_name, last_name, birth_date, email, mobile, gender) VALUES (%s, %s, %s, %s, %s, %s);""", [ 'anon', 'anon', Datetime().date(start=1950, end=2001), None, None, None ]) for _ in range(config.N_PERSONS): p = Person('ru') cursor.execute( """INSERT INTO PersonData (first_name, last_name, birth_date, email, mobile, gender) VALUES (%s, %s, %s, %s, %s, %s);""", [ p.name(), p.surname(), Datetime().date(start=1950, end=2001), p.email(), p.telephone('#' * 11), 'M' if p.gender(iso5218=True) == 1 else 'F' ]) db.commit() cursor.close() db.close()
def generatorGender(): person = Person('ru') gend = person.gender() if gend == 'Муж.': return 'M' else: return 'F'
def create_personalData(): # function of generate new client data passport = '' person = Person('ru') # Выводим исландские мужские имена. lastname = person.last_name() personalData['lastname'] = lastname # print('\nфамилия:\t', personalData['lastname']) name = person.name() personalData['name'] = name # print('имя:\t\t', personalData['name']) surname = person.surname() personalData['surname'] = surname # print('отчество:\t', personalData['surname']) gender = person.gender() personalData['gender'] = gender # print('пол:\t\t', personalData['gender']) for _ in range(2): varLet = random.choice(string.ascii_uppercase) passport += varLet passport += person.telephone('#######') personalData['passport'] = passport # print('паспорт:\t', personalData['passport']) ### birthday currentDate() personalData['age'] = age personalData['age'][2] = str( int(personalData['age'][2]) - person.age(16, 70)) # print('возраст:\t', personalData['age'], '\n') ### # print('гражд-во:\t', person.get_current_locale()) # print('Нац-сть:\t',person.nationality()) ### mobile mobile = person.telephone('+37529#######') personalData['mobile'] = mobile # print('телефон:\t', personalData['mobile']) ### ### email # personalData['email'] = person.email() # print('email:\t\t', personalData['email']) ### # print('проф-ия:\t', person.occupation(), '\n') # print('обращение:\t', person.title()) # print('взгляды:\t', person.views_on()) # print('вера:\t\t', person.worldview(), '\n') return personalData
def create_person(): from mimesis import Person as MimesisPerson, locales, Address person = MimesisPerson(locales.RU) address = Address(locales.RU) with transaction.atomic(): first_name = person.name() last_name = person.surname() gender = person.gender() if gender == 'Муж.': patronymic = choice([ 'Сергеевич', 'Николаевич', 'Артурович', 'Константинович', 'Игоревич' ]) else: patronymic = choice([ 'Александровна', 'Борисовна', 'Петровна', 'Юрьевна', 'Анатольевна' ]) birth_date = generate_birthdate() address = '{}, {}'.format(address.federal_subject(), address.address()) passport_series = randint(1000, 7000) passport_number = randint(100000, 999999) pair = generate_RSA_pair() signature_public_key = pair[1] load_key_to_file( '../../../person_signature_private_keys/{}_{}_{}_{}.pem'.format( passport_series, passport_number, last_name, first_name), pair[0]) person_info = '{} {} {} {} {} {} {} {}'.format( first_name, last_name, patronymic, birth_date, address, passport_series, passport_number, signature_public_key) signature_i = sign_person_info(person_info) Person(first_name=first_name, last_name=last_name, patronymic=patronymic, birth_date=birth_date, address=address, passport_series=passport_series, passport_number=passport_number, signature_public_key=signature_public_key, signature_i=signature_i).save()
def generate_student() -> dict: """Generate a student record.""" person = Person() student = { "academic_degree": person.academic_degree(), "age": person.age(), "full_name": person.full_name(), "gender": person.gender(), "nationality": person.nationality(), "university": person.university(), } return student
def person( cls, *, locale=Locales.EN, qualification=None, age=None, blood_type=None, email=None, first_name=None, last_name=None, gender=None, height=None, id=None, language=None, nationality=None, occupation=None, phone=None, title=None, university=None, weight=None, work_experience=None, ): ''' Create an Person Data Entity object. All individual fields are automatically randomly generated based on locale. If provided, the corresponding values are overriden. Note: All individual fields are randomly generated. Don't expect correct correlation e.g. correct postal code for the generated city. Keyword Arguments: locale: Approprite Random.locale.<local_name> object. Default is Random.locale.EN qualification: Educational Qualification age: Age blood_type: Blood type email: Email address first_name: First name last_name: Last name gender: Gender height: Height id: Identifier language: Language nationality: Nationality occupation: Occupation phone: Phone number title: Title university: University weight: Weight work_experience: Work Experience ''' person = Person(locale=locale) from arjuna.engine.data.entity.person import Person as ArjPerson first_name = first_name is not None and first_name or person.first_name( ) last_name = last_name is not None and last_name or person.last_name() return ArjPerson( qualification=qualification is not None and qualification or person.academic_degree(), age=age is not None and age or person.age(), blood_type=blood_type is not None and blood_type or person.blood_type(), email=email is not None and email or person.email(), first_name=first_name, last_name=last_name, name=first_name + " " + last_name, gender=gender is not None and gender or person.gender(), height=height is not None and height or person.height(), id=id is not None and id or person.identifier(), language=language is not None and language or person.language(), nationality=nationality is not None and nationality or person.nationality(), occupation=occupation is not None and occupation or person.occupation(), phone=phone is not None and phone or person.telephone(), title=title is not None and title or person.title(), university=university is not None and university or person.university(), weight=weight is not None and weight or person.weight(), work_experience=work_experience is not None and work_experience or person.work_experience(), )
noise = noise_ampl*np.random.normal(0.01, 1.7, df.shape[0]) gated_age = np.heaviside(df[age] - min_age, 0.5) - np.heaviside(df[age] - max_age, 0.5) return 0.01*pow(np.abs(df[age] - 30), 2.5) + df[age] + 50*df[marketing_level]*gated_age + 2*df[account_balance] + noise ################################################## ################################################## ### Generate a DataFrame of user information ################################################## # Generate 10,000 rows of the following: # user_id, first_name, last_name, email, password, address, # birth_date, credit_card_num, credit_card_exp, security_answer, # account_balance user_df = pd.DataFrame([[x, person.name(), person.surname(), person.gender(), person.email(), hashed_passwd(person.password()), address.address(), person.age(), payment.credit_card_number(), payment.credit_card_expiration_date(), text.word(), account_balance(), np.random.randint(1, 11)] for x in range(10000)]) user_df.columns = ["user_id", "first_name", "last_name", "gender", "email", "password_hashed", "address", "age", "credit_card_num", "credit_card_exp", "security_answer", "account_balance", "marketing_level"] # Generate sales, based on a noisy linear model user_df['sales'] = generate_sales(user_df)
################################################## ################################################## ### Generate a DataFrame of user information ################################################## # Generate 10,000 rows of the following: # user_id, first_name, last_name, email, password, address, # birth_date, credit_card_num, credit_card_exp, security_answer, # account_balance user_df = pd.DataFrame([[ x, person.name(), person.surname(), person.gender(), person.email(), hashed_passwd(person.password()), address.address(), person.age(), payment.credit_card_number(), payment.credit_card_expiration_date(), text.word(), account_balance(), np.random.randint(1, 11) ] for x in range(10000)]) user_df.columns = [ "user_id", "first_name", "last_name", "gender", "email", "password_hashed", "address", "age", "credit_card_num", "credit_card_exp", "security_answer", "account_balance", "marketing_level"