Heatmap "different values" error

Hi there!

I get this different values error when generating the heatmap. I already saw that one problem might be the matplotlib version but i tried v3.2.2, v3.3.0 and v3.3.2.
I also have matplotlib 3.3.2 on my PC and in jupyter notebook i get the right chart, as far as i can tell visually.
Any advice on what i should do to fix this?

Here’s my repl: https://repl.it/@ungureanudaniel/boilerplate-medical-data-visualizer-1#medical_data_visualizer.py

:pray:

I can’t get it to run (reporting that pandas isn’t installed, although it’s in the packages list).

However, one thing I think is an error is your filter for “overweight”, which is excluding when the ratio is less than 25 - overweight should also exclude when ratio equals 25.

Since I can’t test, not sure whether that gets you a pass or not.

1 Like

If I run your code with self.maxDiff = None on the the test, it says:

FAIL: test_heat_map_values (test_module.HeatMapTestCase)
----------------------------------------------------------------------
...
Second list contains 13 additional elements.

If you look at the generated heatmap.png, the bottom row of the graph is missing, hence the missing elements. Since you are just cleaning data for the heatmap, that is where the problem must be (I verified that with my code). There are two problems here:

    df_heat = df[df['ap_lo'] <= df['ap_hi']]
    df_heat = df[df['height']<=df['height'].quantile(0.025)]
    df_heat = df[df['height']>df['height'].quantile(0.975)]
    df_heat = df[df['weight']<=df['weight'].quantile(0.025)]
    df_heat = df[df['weight']>df['weight'].quantile(0.975)]

One, the conditions are backwards. You want to eliminate things below the lower quantile and above the upper quantile, not the other way around. Second, you have to and these conditions together into one selection command. As it is written, I think only your last line is creating df_heat, selecting the records with weights greater than 97.5% of the population. You want all the records that are between the quantiles (inclusive) and with the correct blood pressures.

Good luck.

1 Like

Thank you both! Those were the problems. It works now. Problems created by my stupid lack of focus, while working on these projects at midnight.

But a great way to learn!