Data Analysis with Python Projects - Medical Data Visualizer

Tell us what’s happening:
Recieving quite a few error messages despite returning the appropriate objefcts with similar formatting to the requested charts.

Issue 1 is an error I think that is related to the current implementation of the unit tests verifying tick labels, this warning also refuses to be suppressed with a pendingdeprecation filter

Issue 2 is the correlation matrix adds 3 empty strings causing a unit test failure. I have no explaination for this

issue 3 i think is the same as issue 1: numpy.ndarray’ object has no attribute 'get_children

not sure where to go from here as my results in image are correct

Your code so far
https://replit.com/@ShaneBarrel/boilerplate-medical-data-visualizer#main.py

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0

Challenge: Data Analysis with Python Projects - Medical Data Visualizer

Link to the challenge:

Replit will not attach so adding here markdown code block

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np


# Import data
df = pd.read_csv('medical_examination.csv')

# add bmi column

# Add 'overweight' column
df['overweight'] = (df['weight'] / ((df['height'] / 100) ** 2) > 25).astype(int)
# Normalize data by making 0 always good and 1 always bad. If the value of 'cholesterol' or 'gluc' is 1, make the value 0. If the value is more than 1, make the value 1.

df[['cholesterol', 'gluc']] = (df[['cholesterol', 'gluc']] > 1).astype(int) 

# Draw Categorical Plot
def draw_cat_plot():
    # Create DataFrame for cat plot using `pd.melt` using just the values from 'cholesterol', 'gluc', 'smoke', 'alco', 'active', and 'overweight'.
    melt = pd.melt(df, id_vars=['cardio'], value_vars=['cholesterol', 'gluc', 'smoke', 'alco', 'active', 'overweight'])


    # modified process from original project as the correct figure can be made without instantiating extra variables and processes bringing line count and memory down significantly
  
    sns.catplot(x='variable', col='cardio', data=melt, kind='count', hue='value')


    # Get the figure for the output
    fig = sns.catplot(x='variable', col='cardio', data=melt, kind='count', hue='value')


    # Do not modify the next two lines
    fig.savefig('catplot.png')
    return fig


# Draw Heat Map
def draw_heat_map():
    # 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))]

    # Calculate the correlation matrix
    corr = df_heat.corr()

    # 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()'

    sns.heatmap(corr, annot=True, fmt='.1f', mask=mask, vmax=.3, center=0, square=True, linewidths=.5, cbar_kws={"shrink": .5})


    # Do not modify the next two lines
    fig.savefig('heatmap.png')
    return fig

The ‘live preview’ feature is flaky. If you put < > around your link, it will show up as a link.

These are all common issues caused by dependency version problems. Numerous threads in the forums about the python data analysis projects will show you how to fix your pyproject.toml and update your dependencies.

Thanks,

Is there anything wrong with just uploading the results from github wrapped in my VenV natively or is it a requirement to use replit?