Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.2 kB
7
Indexable
Never
username = os.getlogin()
higher_ed = pd.read_excel(r"C:\Users\{}\HIP Investor Dropbox\HIP Investor Team Folder\Ania Resources\Python\Data_Complete_Input.xlsx".format(username))

#Sets up classification by the columne in raw data called "Type" (so here just change your peer group column name)
#Also gets rid of NAs for peer groups that only had NAs (this was blocking the process, when running the code)
classification = list(higher_ed['Type'].unique())
classification = list(filter(lambda value: type(value) != float or not math.isnan(value), classification))
print(classification)

#This one loops the code around the peer groups by setting classtype per the column "Type"
#Second part of the code (after the space) is an actual code for running whatever we want to have (in this case it's a correlation heatmap)
for classtype in classification:
    higher_ed_by_class = higher_ed[higher_ed['Type'] == classtype]

    plt.figure(figsize=(45, 30))
    plt.title(classtype)
    sns.heatmap(higher_ed_by_class.corr())
    heatmap = sns.heatmap(higher_ed_by_class.corr(), vmin=-1, vmax=1, annot=True)
    plt.savefig('heatmap_per_class_{}.jpg'.format(classtype))