O: This function needs to be completed. Suggested steps: 1. Create list of
Question:
O: This function needs to be completed.
Suggested steps:
1. Create list of normal patients (hf_events.csv only contains information about heart failure patients).
2. Split events into two groups based on whether the patient has heart failure or not.
3. Calculate index vid for each patient.
IMPORTANT:
`indx_vid` should be a pd dataframe with header `['pid', 'indx_vid']`.
'''
hf_patients = events.loc[events.pid.isin(hf)]
norm_patients = events.loc[~events.pid.isin(hf)]
norm_patients= norm_patients.sort_values(by=['pid', 'vid'])
vidcount_norm = (norm_patients.groupby("pid")["vid"].max())
print(len(vidcount_norm))
vidcount_hf = (hf_patients.groupby("pid")["vid"].min())
print(len(vidcount_hf))
#vidcount_hf[50285]=3
#print(vidcount_hf[50285])
#print(vidcount_hf[98085]) #=5
#print(vidcount_norm[20853])#=1
#print(vidcount_norm[47877]) #=1
f1 = pd.DataFrame({'pid':vidcount_norm.index, 'indx_vid':vidcount_norm.values})
f2 = pd.DataFrame({'pid':vidcount_hf.index, 'indx_vid':vidcount_hf.values})
f4 = dict(list(zip(f2.pid, f2.indx_vid)))
#print(f4)
f3 = pd.concat([f1, f2], axis=0)
f3 = f3.sort_values(by=['pid'])
#f4 = pd.DataFrame({'pid':f3.index, 'indx_vid':f3.values})
indx_vid = f3
print(indx_vid.shape)
print(f3[f3.pid == 78])
print(f3[f3.pid == 1230])
#print(indx_vid)
#indx_vid1 = dict(list(zip(indx_vid_df.pid, indx_vid_df.indx_vid)))
#print(indx_vid1)
# your code here
#raise NotImplementedError
return indx_vid
Management Accounting Information for Decision-Making and Strategy Execution
ISBN: 978-0137024971
6th Edition
Authors: Anthony A. Atkinson, Robert S. Kaplan, Ella Mae Matsumura, S. Mark Young