In [1]:
import pandas as pd
In [2]:
df = pd.read_csv('files/all_claims_files.csv')
In [3]:
# Create an ExcelWriter object representing the workbook location that can be used to hold sheets
xlwriter = pd.ExcelWriter('case_management_report.xlsx', engine='xlsxwriter')
In [4]:
disease_cols = ['SP_ALZHDMTA',
'SP_CHF', 'SP_CHRNKIDN', 'SP_CNCR', 'SP_COPD', 'SP_DEPRESSN',
'SP_DIABETES', 'SP_ISCHMCHT', 'SP_OSTEOPRS', 'SP_RA_OA', 'SP_STRKETIA']
In [5]:
for disease in disease_cols:
disease_df = df.query(disease + '==1') # Filter the Data Frame for only rows with that disease
disease_df.to_excel(xlwriter, sheet_name=disease) # Pass the ExcelWriter object and define a sheet name
In [6]:
xlwriter.save() # Save the workbook by calling the save method on the ExcelWriter object
In [ ]: