32 lines
1.6 KiB
Python
32 lines
1.6 KiB
Python
import pandas as pd
|
|
import os
|
|
import numpy as np
|
|
|
|
curdir = os.getcwd()
|
|
path_delim = '/'
|
|
df1 = pd.read_excel(curdir + path_delim + "data/July_Sept3.xlsx", sheet_name="op")
|
|
df2 = pd.read_excel(curdir + path_delim + "data/diff_check.xlsx", sheet_name="op")
|
|
|
|
print(df2)
|
|
df = df2.merge(df1, on="_id", how='outer')
|
|
print(df.columns)
|
|
# df = pd.concat([df1, df3], ignore_index=True)
|
|
df['Age'] = 2023 - df['birthYear']
|
|
|
|
|
|
df = df[["_id", "name", "abhaId", "aadharId", "Age", "gender", "category", "maritalStatus", "house", "district", "state", "pinCode", "phoneNumber", "Test Result_x", "bloodGroup", "createdAt", "Caste"]]
|
|
# print(df.columns)
|
|
|
|
df.rename(columns={'_id': "Sample ID", "name": "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", "Test Result_x": "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.loc[df['Test Result'] == np.nan, 'Test Result'] = 'Retest'
|
|
# df.loc[df['Test Result'] == "Inconclusive", 'Test Result'] = 'Retest'
|
|
print(df)
|
|
|
|
writer = pd.ExcelWriter(curdir + path_delim + "data/July_Sept4.xlsx", engine = 'openpyxl')
|
|
df.to_excel(writer, sheet_name = 'op', index=False)
|
|
writer.close()
|
|
|