Medical Data Visualizer - Issue with heat map

Hi All, The expected heat map is having values rounded off to tenths decimal place(e.g 0.342 to 0.3). So when I run “round(corr,1)”, all the values are coming correct as expected, except 0 (0.0025 is displayed as 0), however it is expected to be displayed as 0.0, but round function is converting it to only 0. Hence I am receiving this error.

File “/home/runner/fcc-medical-data-visualizer-1/test_module.py”, line 47, in test_heat_map_values
self.assertEqual(actual, expected, “Expected differnt values in heat map.”)
AssertionError: Lists differ: [‘0’, ‘0’, ‘-0’, ‘0’, ‘-0.1’, ‘0.5’, ‘0’, '0[520 chars], ‘’] != [‘0.0’, ‘0.0’, ‘-0.0’, ‘0.0’, ‘-0.1’, ‘0.5’,[626 chars], ‘’]

First differing element 0:
‘0’
‘0.0’

Expected Image :

Actual Image :


**

**Your code so far

sns.heatmap(round(corr,1), linewidths=1, mask=mask, vmax=.3, center=0.05,square=True, cbar_kws = {‘orientation’ : ‘vertical’},annot=True)
**

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36.

Challenge: Medical Data Visualizer

Link to the challenge:

Don’t bother with rounding your correlation. You can pass a fmt='.1f' parameter to sns.heatmap() to format the labels (annotations) on the heatmap and they will be rounded to the requested precision.

2 Likes

Thanks!! That worked :slight_smile: