Medical Data Visualizer - Heat Map different values

Hi, I’m working hard on the data analysis with Python course.
On the medical data visualizer, I pass all the tests but the heat map values’ one.
I tried looking at my data cleaning and I also tried to update matplotlib, but no dice, can’t see the problem. This is the error I get, after I tried changing matplotlib to 3.2.2 in poetry.lock

FAIL: test_heat_map_values (test_module.HeatMapTestCase)

Traceback (most recent call last):
File “/home/runner/boilerplate-medical-data-visualizer/test_module.py”, line 48, in test_heat_map_values
self.assertEqual(actual, expected, “Expected different values in heat map.”)
AssertionError: Lists differ: ['0.0[607 chars] ‘0.2’, ‘0.1’, ‘0.1’, ‘-0.0’, ‘0.0’, ‘-0.0’, ‘0.1’, ‘’, ‘’, ‘’] != ['0.0[607 chars] ‘0.2’, ‘0.1’, ‘0.1’, ‘-0.0’, ‘0.0’, ‘-0.0’, ‘0.1’]

First list contains 3 additional elements.
First extra element 91:
‘’

[‘0.0’,
‘0.0’,
‘-0.0’,
‘0.0’,
‘-0.1’,
‘0.5’,
‘0.0’,
‘0.1’,
‘0.1’,
‘0.3’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.2’,
‘0.1’,
‘0.0’,
‘0.2’,
‘0.1’,
‘0.0’,
‘0.1’,
‘-0.0’,
‘-0.1’,
‘0.1’,
‘0.0’,
‘0.2’,
‘0.0’,
‘0.1’,
‘-0.0’,
‘-0.0’,
‘0.1’,
‘0.0’,
‘0.1’,
‘0.4’,
‘-0.0’,
‘-0.0’,
‘0.3’,
‘0.2’,
‘0.1’,
‘-0.0’,
‘0.0’,
‘0.0’,
‘-0.0’,
‘-0.0’,
‘-0.0’,
‘0.2’,
‘0.1’,
‘0.1’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.3’,
‘0.0’,
‘-0.0’,
‘0.0’,
‘-0.0’,
‘-0.0’,
‘-0.0’,
‘0.0’,
‘0.0’,
‘-0.0’,
‘0.0’,
‘0.0’,
‘0.0’,
‘0.2’,
‘0.0’,
‘-0.0’,
‘0.2’,
‘0.1’,
‘0.3’,
‘0.2’,
‘0.1’,
‘-0.0’,
‘-0.0’,
‘-0.0’,
‘-0.0’,
‘0.1’,
‘-0.1’,
‘-0.1’,
‘0.7’,
‘0.0’,
‘0.2’,
‘0.1’,
‘0.1’,
‘-0.0’,
‘0.0’,
‘-0.0’,

  • ‘0.1’,
    ? ^
  • ‘0.1’]
    ? ^
  • ‘’,
  • ‘’,
  • ‘’] : Expected different values in heat map.

Ran 4 tests in 6.809s

And here is my project: https://replit.com/@Murabrasa/boilerplate-medical-data-visualizer#medical_data_visualizer.py

This bit of data cleaning

# Draw Heat Map
def draw_heat_map():
    # Clean the data
    dff = df[~(df["ap_hi"]<df["ap_lo"])]
    dff = dff[~((dff.height<dff.height.quantile(0.025))|(dff.height>dff.height.quantile(0.975)))]
    dff = dff[~((dff.weight<dff.weight.quantile(0.025))|(dff.weight>dff.weight.quantile(0.975)))]

is not correct. This code effectively or's the conditions. You need to and the conditions. There are several discussions of this in the forums if you need examples.

1 Like

My god, such a silly mistake I am embarrassed not to have noticed it. Serves me right for trying to be fancy with the “not” operator and ending up confusing myself!
Thanks a lot!