Data Analysis with Python Projects - Medical Data Visualizer

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:

Strange we just had the same problem here:

https://forum.freecodecamp.org/t/data-analysis-with-python-projects-medical-data-visualizer-heatmap-values/638538/3

Your replit might be corrupt.

Try to fork the replit from this boilerplate link and copy your code back into the new replit.

I attempted to execute the fork code, but now I’m encountering the error message “No module named ‘pandas’.”

On the other 2 projects (mean and demographic) I had to start a new Replit to run them Otherwise, I would get errors.

Traceback (most recent call last):
File “main.py”, line 2, in
import medical_data_visualizer
File “/home/runner/fcc-medical-data-visualizer/medical_data_visualizer.py”, line 1, in
import pandas as pd
ModuleNotFoundError: No module named ‘pandas’

at the shell command prompt type pip install pandas

Always search the forum if you get an error as well, there’s often someone who’s had the same problem. This error has come up many, many times.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.