Tell us what’s happening:
Hello!
I’m encountering an issue when trying to plot the heatmap figure. The problem is that the graph isn’t displaying the numbers within it, and as a result, I’m encountering an error message that looks like this:
FAIL: test_heat_map_values (test_module.HeatMapTestCase)
Traceback (most recent call last):
File “/home/runner/boilerplate-medical-data-visualizer/test_module.py”, line 47, in test_heat_map_values
self.assertEqual(actual, expected, “Expected different values in heat map.”)
AssertionError: Lists differ: [‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, ‘–’, [36 chars]‘–’] != [‘0.0’, ‘0.0’, ‘-0.0’, ‘0.0’, ‘-0.1’, ‘0.5’[615 chars]0.1’]
First differing element 0:
‘–’
‘0.0’
Second list contains 77 additional elements.
First extra element 14:
‘0.0’
Diff is 1062 characters long. Set self.maxDiff to None to see it. : Expected different values in heat map.
Ran 4 tests in 11.399s
FAILED (failures=1)
Does anyone have any tips or suggestions on how to resolve this issue?
Also, when I run on PyCharme, everything goes well.
Your code so far
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(data=corr, annot=True, mask=mask, fmt=“.1f”, linewidth=.5, annot_kws={‘fontsize’:6}, cbar_kws={“shrink”: .7}, square=True, center=0, vmin=-0.09, vmax=0.29)
# Do not modify the next two lines
fig.savefig(‘heatmap.png’)
return fig
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.6 Safari/605.1.15
Challenge: Data Analysis with Python Projects - Medical Data Visualizer
Link to the challenge: