Tell us what’s happening:
AssertionError: Lists differ: [0.0[14 chars]0, '-0.0' '-0.1', '0.5', '0.0', '0.1', '0.1'[594 chars]0.1'] != ['0.0[14 chars]0', '0.0', '-0.1', '0.5', '0.0', '0.1', '0.1',[593 chars]0.1']
First differing element 3:
'-0.0'
'0.0'
Diff is 1178 characters long. Set self.maxDiff to None to see it. : Expected different values in heat map.
Ran 4 tests in 3.294s
FAILED (failures=1)
This is the error I am getting each time, I am unable to fix it as the table expects negative 0 values in some of the cells.
Your code so far
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
# 1
df = pd.read_csv('medical_examination.csv')
Hieght = (df['height']*0.01)
Weight = df['weight']
BMI = Weight/(Hieght**2)
# 2
df['overweight'] = (BMI > 25).astype(int)
# 3
df['cholesterol'] = df['cholesterol'].apply(lambda x:0 if x == 1 else 1)
df['gluc'] = df['gluc'].apply(lambda x:0 if x == 1 else 1)
# 4
def draw_cat_plot():
# 5
df_melt = pd.melt(df,id_vars =['cardio'],value_vars = ['active', 'alco', 'cholesterol', 'gluc', 'overweight', 'smoke'],var_name = 'variable',value_name = 'value')
# 6
df_cat = df_melt
# 7
catplot = sns.catplot(x = "variable",hue = "value",col = 'cardio',kind ='count',data = df_cat)
catplot.set_axis_labels("variable", "total")
# 8
fig = catplot.fig
# 9
fig.savefig('catplot.png')
return fig
# 10
def draw_heat_map():
# 11
df_heat = df[(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))]
# 12
corr = df_heat.corr()
# 13
mask = np.triu(np.ones_like(corr,dtype = bool ))
# 14
fig, ax = plt.subplots(figsize = (10,8))
# 15
heatmap = sns.heatmap(corr,mask = mask,fmt = '.1f', annot = True, cmap = 'coolwarm', linewidths = 0.5, ax = ax)
# 16
fig.savefig('heatmap.png')
return fig
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
Challenge Information:
Data Analysis with Python Projects - Medical Data Visualizer