super_data_len = len(super_data) for i in range(super_data_len): center_state = super_data.at[i, "centerState"] purchase_type = super_data.at[i, "purchaseType"] book_invoice_code = "" ebook_invoice_code = "" prod_invoice_code = "" # Book Invoice Code if super_data.loc[i, "isBook"] == True: if center_state == "Maharashtra": if purchase_type == "Online": counters["mh_sc_cnt"] += 1 book_invoice_code = state_code_mh + year_code + "SCB" + f"{counters['mh_sc_cnt']:08d}" elif purchase_type == "Offline": counters["of_sc_cnt"] += 1 book_invoice_code = state_code_of + year_code + "SCB" + f"{counters['of_sc_cnt']:08d}" elif center_state == "Bihar": counters["br_sc_cnt"] += 1 book_invoice_code = state_code_br + year_code + "SCB" + f"{counters['br_sc_cnt']:08d}" elif center_state == "Delhi": counters["dl_sc_cnt"] += 1 book_invoice_code = state_code_dl + year_code + "SCB" + f"{counters['dl_sc_cnt']:08d}" elif center_state == "Uttar Pradesh": counters["up_sc_cnt"] += 1 book_invoice_code = state_code_up + year_code + "SCB" + f"{counters['up_sc_cnt']:08d}" super_data.at[i, "Invoice_Book"] = book_invoice_code # E-Book Invoice Code if super_data.loc[i, "isEBook"] == True: if center_state == "Maharashtra": if purchase_type == "Online": counters["mh_sc_cnt"] += 1 ebook_invoice_code = state_code_mh + year_code + "SCE" + f"{counters['mh_sc_cnt']:08d}" elif purchase_type == "Offline": counters["of_sc_cnt"] += 1 ebook_invoice_code = state_code_of + year_code + "SCE" + f"{counters['of_sc_cnt']:08d}" elif center_state == "Bihar": counters["br_sc_cnt"] += 1 ebook_invoice_code = state_code_br + year_code + "SCE" + f"{counters['br_sc_cnt']:08d}" elif center_state == "Delhi": counters["dl_sc_cnt"] += 1 ebook_invoice_code = state_code_dl + year_code + "SCE" + f"{counters['dl_sc_cnt']:08d}" elif center_state == "Uttar Pradesh": counters["up_sc_cnt"] += 1 ebook_invoice_code = state_code_up + year_code + "SCE" + f"{counters['up_sc_cnt']:08d}" super_data.at[i, "Invoice_EBook"] = ebook_invoice_code # Product Invoice Code if super_data.loc[i, "isProduct"] == True: if center_state == "Maharashtra": if purchase_type == "Online": counters["mh_sc_cnt"] += 1 prod_invoice_code = state_code_mh + year_code + "SCP" + f"{counters['mh_sc_cnt']:08d}" elif purchase_type == "Offline": counters["of_sc_cnt"] += 1 prod_invoice_code = state_code_of + year_code + "SCP" + f"{counters['of_sc_cnt']:08d}" elif center_state == "Bihar": counters["br_sc_cnt"] += 1 prod_invoice_code = state_code_br + year_code + "SCP" + f"{counters['br_sc_cnt']:08d}" elif center_state == "Delhi": counters["dl_sc_cnt"] += 1 prod_invoice_code = state_code_dl + year_code + "SCP" + f"{counters['dl_sc_cnt']:08d}" elif center_state == "Uttar Pradesh": counters["up_sc_cnt"] += 1 prod_invoice_code = state_code_up + year_code + "SCP" + f"{counters['up_sc_cnt']:08d}" super_data.at[i, "Invoice_Product"] = prod_invoice_code