Skip to content

Commit

Permalink
#5 added zero padding to ensure userids are always 16 digits for case…
Browse files Browse the repository at this point in the history
…s when numeric iso country code is less than 3 digits i.e. belgium and albania
  • Loading branch information
oislen committed Jun 14, 2023
1 parent 9d5fca0 commit aa35dca
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scripts/app/gen_user_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ def gen_user_data(user_obj, device_obj, card_obj, ip_obj, transaction_obj, appli
user_data['registration_date'] = user_data['uid'].replace(user_obj.user_ids_dates_dict)
user_data['registration_country_code'] = user_data['uid'].replace(user_obj.user_ids_country_code_dict)
user_data['email_domain'] = user_data['uid'].replace(user_obj.user_ids_email_domain_dict)
user_data['userid'] = user_data['registration_date'].dt.strftime('%Y%m%d') + user_data['registration_country_code'].astype(str) + user_data['uid'].astype(str).str[-5:]
userid_date_country_code = user_data['registration_date'].dt.strftime('%Y%m%d') + user_data['registration_country_code'].astype(str)
zero_pad = (userid_date_country_code.str.len() - 11).abs().apply(lambda x: '0'*x)
user_data['userid'] = userid_date_country_code + zero_pad + user_data['uid'].astype(str).str[-5:]
# add hash data lists
user_data['device_hash'] = user_data['n_devices'].apply(lambda x: list(np.random.choice(a = list(device_obj.device_hashes_props_dict.keys()), replace = False, size = x)))
user_data['card_hash'] = user_data['n_cards'].apply(lambda x: list(np.random.choice(a = list(card_obj.card_hashes_props_dict.keys()), replace = False, size = x)))
Expand Down

0 comments on commit aa35dca

Please sign in to comment.