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.