I am having problems with the heatmap of the Medical Data Visualizer exercise, at Data Analysis certification. First row does not compute for the visualization:
The code that I used:
# 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))]
df_heat = df_heat.drop(columns='BMI')
# Calculate the correlation matrix
corr = df_heat.corr(method = "pearson")
# Generate a mask for the upper triangle
mask = np.triu(corr)
# Set up the matplotlib figure
fig, ax = plt.subplots(figsize=(12, 12))
# Draw the heatmap with 'sns.heatmap()'
fig = sns.heatmap(corr, linewidths = 1, annot = True, square = True, mask = mask, fmt = ".1f", center = 0.08, cbar_kws = {"shrink":0.5}).get_figure()
# Do not modify the next two lines
fig.savefig('heatmap.png')
Thanks!