Hello everyone,
First of all, apologies for creating yet another thread about this issue, but the reality is none of the ones I found were able to solve my problem… I keep getting the following error in the heatmap exercise:
FAIL: test_heat_map_values (test_module.HeatMapTestCase)
Traceback (most recent call last):
File “/home/runner/boilerplate-medical-data-visualizer-2/test_module.py”, line 48, in test_heat_map_values
self.assertEqual(actual, expected, “Expected different values in heat map.”)
AssertionError: Lists differ: [‘0.0[569 chars], ‘0.0’, ‘-0.0’, ‘-0.0’, ‘0.4’, ‘0.0’, ‘0.1’, [38 chars]0.1’] != [‘0.0[569 chars], ‘0.1’, ‘-0.1’, ‘-0.1’, ‘0.7’, ‘0.0’, ‘0.2’, [38 chars]0.1’]First differing element 79:
‘0.0’
‘0.1’[‘0.0’,
‘0.0’,
‘-0.0’,
‘0.0’,
‘-0.1’,
‘0.5’,
‘0.0’,
‘0.1’,
‘0.1’,
‘0.3’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.2’,
‘0.1’,
‘0.0’,
‘0.2’,
‘0.1’,
‘0.0’,
‘0.1’,
‘-0.0’,
‘-0.1’,
‘0.1’,
‘0.0’,
‘0.2’,
‘0.0’,
‘0.1’,
‘-0.0’,
‘-0.0’,
‘0.1’,
‘0.0’,
‘0.1’,
‘0.4’,
‘-0.0’,
‘-0.0’,
‘0.3’,
‘0.2’,
‘0.1’,
‘-0.0’,
‘0.0’,
‘0.0’,
‘-0.0’,
‘-0.0’,
‘-0.0’,
‘0.2’,
‘0.1’,
‘0.1’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.3’,
‘0.0’,
‘-0.0’,
‘0.0’,
‘-0.0’,
‘-0.0’,
‘-0.0’,
‘0.0’,
‘0.0’,
‘-0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.2’,
‘0.0’,
‘-0.0’,
‘0.2’,
‘0.1’,
‘0.3’,
‘0.2’,
‘0.1’,
‘-0.0’,
‘-0.0’,
‘-0.0’,
‘-0.0’,
- ‘0.1’,
- ‘-0.1’,
- ‘-0.1’,
- ‘0.7’,
‘0.0’,
- ‘-0.0’,
- ‘-0.0’,
- ‘0.4’,
? ^
- ‘0.2’,
? ^
- ‘0.0’,
‘0.1’,
‘0.1’,- ‘0.0’,
‘-0.0’,
‘0.0’,
‘-0.0’,
‘0.1’] : Expected different values in heat map.
I have looked and relooked at my code, and nothing seems to explain why this is happening… Here is the code:
# Draw Heat Map
def draw_heat_map():
# Clean the data
df_heat = df[(df['ap_lo'] <= df['ap_hi']) &
(df['height'] >= (df['height'].quantile(0.025))) &
(df['height'] <= (df['height'].quantile(0.975))) &
(df['weight'] >= (df['weight'].quantile(0.025))) &
(df['weight'] <= (df['weight'].quantile(0.975)))]
# Calculate the correlation matrix
corr = df_heat.corr()
# Generate a mask for the upper triangle
mask = np.triu(np.ones_like(corr, dtype=bool))
# Set up the matplotlib figure
fig, ax = plt.subplots()
# Draw the heatmap with 'sns.heatmap()'
sns.heatmap(corr,
mask=mask,
vmax=.3,
square=True,
linewidths=.5,
annot = True,
fmt='.1f')
# Do not modify the next two lines
fig.savefig('heatmap.png')
return fig
You can access the link here as well, in case it is helpful: https://replit.com/@DiogoSilvano/boilerplate-medical-data-visualizer-2#medical_data_visualizer.py
Thank you!