'How to generate one heatmap under loop?

I have two datasets with different rows and columns, so I have applied this method but I am not able to generate its Heatmap. I want to generate heatmap of highly correlated metabolome.

for feature in dataset_1.index.tolist():
#print(feature)
if feature in dataset_2.index.tolist():
    random.seed(23)
    reg,P_val=pearsonr(random.sample(dataset_1.T[feature].tolist(),22), random.sample(dataset_2.T[feature].tolist(),22))
    #print(feature,reg,P_val)
    if reg >= 0.4 or reg <=-0.4:
        print(reg)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source