# Medical Data Visualizer Project - Not getting same correlation values

Hi,

unfotunately im not getting the exact same correlation values in my heatmap. They differ by 0.1 at two instances. The test_module outputs one failure. See in the following my solution and the test_module output.

Best regards
M

My solution
def draw_heat_map():
# Clean the data
df_heat = df.copy()
df_heat =df_heat.loc[(df_heat[‘ap_lo’] <= df_heat[‘ap_hi’]),:]
df_heat =df_heat.loc[(df_heat[‘height’] >= df_heat[‘height’].quantile(0.025)),:]
df_heat =df_heat.loc[(df_heat[‘height’] <= df_heat[‘height’].quantile(0.975)),:]
df_heat =df_heat.loc[(df_heat[‘weight’] >= df_heat[‘weight’].quantile(0.025)),:]
df_heat =df_heat.loc[(df_heat[‘weight’] <= df_heat[‘weight’].quantile(0.975)),:]
new_order = [‘id’, ‘age’, ‘sex’, ‘height’, ‘weight’, ‘ap_hi’, ‘ap_lo’, ‘cholesterol’, ‘gluc’, ‘smoke’, ‘alco’, ‘active’, ‘cardio’, ‘overweight’]
df_heat = df_heat.loc[:,new_order]
# Calculate the correlation matrix
corr = df_heat.corr()

``````# Generate a mask for the upper triangle

for i in range(int(corr.shape[0])):

# Set up the matplotlib figure
fig,ax = plt.subplots()

# Draw the heatmap with 'sns.heatmap()'

# Do not modify the next two lines
fig.savefig('heatmap.png')
return fig
``````

test_module output
AssertionError: Lists differ: ['0.0[59 chars], ‘0.2’, ‘0.0’, ‘0.0’, ‘0.0’, ‘0.0’, ‘0.0’, ‘0[548 chars]0.1’] != ['0.0[59 chars], ‘0.3’, ‘0.0’, ‘0.0’, ‘0.0’, ‘0.0’, ‘0.0’, ‘0[548 chars]0.1’]
First differing element 9:
‘0.2’
‘0.3’
Diff is 1023 characters long. Set self.maxDiff to None to see it. : Expected different values in heat map.

I solved it myself

df_heat =df_heat.loc[(df_heat[‘ap_lo’] <= df_heat[‘ap_hi’]),:]
df_heat =df_heat.loc[(df_heat[‘height’] >= df_heat[‘height’].quantile(0.025)),:]
df_heat =df_heat.loc[(df_heat[‘height’] <= df_heat[‘height’].quantile(0.975)),:]
df_heat =df_heat.loc[(df_heat[‘weight’] >= df_heat[‘weight’].quantile(0.025)),:]
df_heat =df_heat.loc[(df_heat[‘weight’] <= df_heat[‘weight’].quantile(0.975)),:]

has to be

df_heat =df_heat.loc[(df_heat[‘ap_lo’] <= df_heat[‘ap_hi’]) &
(df_heat[‘height’] >= df_heat[‘height’].quantile(0.025)) &
(df_heat[‘height’] <= df_heat[‘height’].quantile(0.975)) &
(df_heat[‘weight’] >= df_heat[‘weight’].quantile(0.025)) &
(df_heat[‘weight’] <= df_heat[‘weight’].quantile(0.975)),:]