combine4
This commit is contained in:
@@ -1,33 +1,35 @@
|
||||
import pandas as pd
|
||||
import os
|
||||
import numpy as np
|
||||
|
||||
curdir = os.getcwd()
|
||||
path_delim = '/'
|
||||
df1 = pd.read_excel(curdir + path_delim + "data/diff_check.xlsx", sheet_name="Sheet3")
|
||||
# df2 = pd.read_excel(curdir + path_delim + "data/all_users_14_07_2023_to_12_09_2023.xlsx", sheet_name="Sheet2")
|
||||
df1 = pd.read_csv(curdir + path_delim + "data/all_users_14_07_2023_to_12_09_2023.csv")
|
||||
df2 = pd.read_csv(curdir + path_delim + "data/tests_14_07_2023_to_12_09_2023.csv")
|
||||
df3 = pd.read_excel(curdir + path_delim + "data/diff_check.xlsx", sheet_name="Sheet3")
|
||||
# df3 = pd.read_excel(curdir + path_delim + "data/July_Sept3 copy.xlsx", sheet_name="op")
|
||||
|
||||
print(df2)
|
||||
df = df1.merge(df2, on="_id")
|
||||
master_df = df
|
||||
|
||||
### merging July
|
||||
### merging July
|
||||
df = df1.merge(df2, on="_id", how='outer')
|
||||
df = df3.merge(master_df, on="_id")
|
||||
print(df.columns)
|
||||
# df = pd.concat([df1, df3], ignore_index=True)
|
||||
|
||||
|
||||
df = df[["_id", "name_x", "abhaId_x", "aadharId", "Age", "gender_x", "Category", "maritalStatus", "house", "district", "state_x", "pinCode", "phoneNumber", "Test Result", "bloodGroup", "Created Dates", "caste"]]
|
||||
# print(df.columns)
|
||||
|
||||
df.rename(columns={'_id': "Sample ID", "name": "Name", "abhaId_x": "ABHA ID", "aadharId": "Aadhaar ID", "gender_x": "Gender", "Category": "Category", "maritalStatus": "Marital Status", "house": "Address", "district": "District", "state_x": "State", "pinCode": "Pincode", "phoneNumber": "Mobile Number", "Created Dates": "Test Date", "Test Result": "Test Result", "bloodGroup": "Blood Group", "Age_x": "Age", "name_x": "Name", "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", "Test Date", "Test Result", "Blood Group"], axis=1)
|
||||
df['Test Date'] = pd.to_datetime(df["Test 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)
|
||||
|
||||
# sample_ids = df["_id"].tolist()
|
||||
# print(len(sample_ids))
|
||||
|
||||
print(len(df['_id']) - len(df['_id'].drop_duplicates()))
|
||||
|
||||
# df_dup = df['_id']-df['_id'].drop_duplicates()
|
||||
# print(df_dedup)
|
||||
|
||||
# dfut = pd.merge(df1, df2, how='outer',
|
||||
# left_index=True, right_on=['_id', 'Sample ID'],
|
||||
# indicator=True)
|
||||
|
||||
# print(dfut)
|
||||
# dfut.query('_merge != "both"')
|
||||
|
||||
writer = pd.ExcelWriter(curdir + path_delim + "data/July_Sept3.xlsx", engine = 'openpyxl')
|
||||
df.to_excel(writer, sheet_name = 'op', index=False)
|
||||
writer.close()
|
||||
|
||||
Reference in New Issue
Block a user