import pandas as pd import os import numpy as np curdir = os.getcwd() path_delim = '/' df1 = pd.read_excel(curdir + path_delim + "data/users_25_09_2023_16_17.xlsx", sheet_name="Sheet1") df2 = pd.read_excel(curdir + path_delim + "data/FinalResults_ToDeclar25sept.xlsx", sheet_name="data") df = df1.merge(df2, on="_id", how='outer') print(df.columns) # # df = pd.concat([df1, df3], ignore_index=True) df['Age'] = 2023 - df['birthYear'] df = df[["_id", "name_x", "abhaId", "aadharId", "Age", "gender", "category", "maritalStatus", "house", "district", "state", "pinCode", "phoneNumber", "classificationResult", "bloodGroup", "createdAt", "caste"]] print(df) df.rename(columns={'_id': "Sample ID", "name_x": "Name", "abhaId": "ABHA ID", "aadharId": "Aadhaar ID", "gender": "Gender", "category": "Category", "maritalStatus": "Marital Status", "house": "Address", "district": "District", "state": "State", "pinCode": "Pincode", "phoneNumber": "Mobile Number", "createdAt": "Date", "classificationResult": "Test Result", "bloodGroup": "Blood Group", "Age": "Age", "caste": "Caste"}, inplace = True) df = df.reindex(["Sample ID", "Name", "ABHA ID", "Aadhaar ID", "Age", "Gender", "Caste", "Category", "Marital Status", "Address", "District", "State", "Pincode", "Mobile Number", "Date", "Test Result", "Blood Group"], axis=1) # df['Date'] = pd.to_datetime(df["Date"].dt.strftime('%d-%m-%Y')) # df = df.sort_values(by=['Date'], ascending=True) df_final = df df_final.loc[df_final['Test Result'] == 'Normal', 'Test Result'] = 'Normal (HbA)' df_final.loc[df_final['Test Result'] == 'Sickle Cell Trait', 'Test Result'] = 'Sickle Cell Trait (HbAS)' df_final.loc[df_final['Test Result'] == 'SCT', 'Test Result'] = 'Sickle Cell Trait (HbAS)' df_final.loc[df_final['Test Result'] == 'SCD', 'Test Result'] = 'Sickle cell Disease (HbSS)' df_final.loc[df_final['Test Result'] == 'PBL', 'Test Result'] = 'Positive Borderline' df_final.loc[df_final['Test Result'] == 'NBL', 'Test Result'] = 'Negative Borderline' df_final.loc[df_final['Gender'] == 'Male', 'Gender'] = 'MALE' df_final.loc[df_final['Gender'] == 'Female', 'Gender'] = 'FEMALE' print(df_final.groupby(["Test Result"]).describe()) writer = pd.ExcelWriter(curdir + path_delim + "data/Sept25.xlsx", engine = 'openpyxl') df_final.to_excel(writer, sheet_name = 'op', index=False) writer.close()