Medical Data Visualizer
Hi,
I am not able to resolve a silly issue in the above project.
My code is done already, however I have issue with the last test.
The self.ax.get_default_bbox_extra_artists()
method returns an object with several Text object and at the end three different matplotlib object.
The next line is create the actual list with the data values.
Every single values are equal with the expected list, except the last three value.
In the expected list the last three elements are empty string: ""
In the actual list these empty strings missing.
I cannot to find what is the solution, and more worst I do not find any mistake in the code…
this is the affected code snippet:
def draw_heat_map():
# Clean the data
# https://cmdlinetips.com/2018/02/how-to-subset-pandas-dataframe-based-on-values-of-a-column/
pressure_filter = df["ap_lo"] <= df["ap_hi"]
height_filter = (df["height"] >= df["height"].quantile(0.025)) & (df["height"] <= df["height"].quantile(0.975))
weight_filter = (df["weight"] >= df["weight"].quantile(0.025)) & (df["weight"] <= df["weight"].quantile(0.975))
df_heat = df[pressure_filter & height_filter & weight_filter]
# Calculate the correlation matrix
# https://seaborn.pydata.org/examples/many_pairwise_correlations.html
corr = df_heat.corr()
# Generate a mask for the upper triangle
# https://seaborn.pydata.org/generated/seaborn.heatmap.html
mask = np.triu(np.ones_like(corr, dtype = bool))
# Set up the matplotlib figure
fig, ax = plt.subplots(figsize=(11, 9))
# Draw the heatmap with 'sns.heatmap()'
# https://seaborn.pydata.org/generated/seaborn.heatmap.html
sns.heatmap(
corr,
mask = mask,
linewidths = 0.5,
annot = True, # If True, write the data value in each cell.
fmt = ".1f", # String formatting code to use when adding annotations.
center = 0.08,
cbar_kws = {
"shrink": 0.5 # half the size if colorbar
}
)
# Do not modify the next two lines
fig.savefig('heatmap.png')
return fig
Is anyone has an idea?
The full code on Repl.
lendoo