# Data Analysis with Python Projects - Medical Data Visualizer

Tell us what’s happening:

Please run it on your end for me to check whether it is something on my end or on Replit. The code seems to be producing the correct graph on Jupyter Notebook.

https://replit.com/@StephenChan1/boilerplate-medical-data-visualizer-1#medical_data_visualizer.py

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

# Import data

df['overweight'] = df["weight"] / ((df["height"]/100) ** 2)
df.loc[df["overweight"] > 25, "overweight"] = 1
df.loc[df["overweight"] != 1, "overweight"] = 0

# 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.loc[df["cholesterol"] == 1, "cholesterol"] = 0
df.loc[df["cholesterol"] > 1, "cholesterol"] = 1

df.loc[df["gluc"] == 1, "gluc"] = 0
df.loc[df["gluc"] > 1, "gluc"] = 1

# 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'.
df_cat = df.melt(value_vars=['cholesterol', 'gluc', 'smoke', 'alco', 'active', 'overweight'])

# Group and reformat the data to split it by 'cardio'. Show the counts of each feature. You will have to rename one of the columns for the catplot to work correctly.
df_cat = df.melt(id_vars=["cardio"], value_vars=['cholesterol', 'gluc', 'smoke', 'alco', 'active', 'overweight'])
df_cat = pd.DataFrame(data=df_cat.value_counts(), columns=["total"]).sort_index().reset_index()

# Draw the catplot with 'sns.catplot()'

fig = sns.catplot(x="variable", y="total", hue="value", col="cardio",data=df_cat, kind="bar")

# 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.loc[(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

# Set up the matplotlib figure
fig, ax = plt.subplots(figsize=(11, 9))

# Draw the heatmap with 'sns.heatmap()'

sns.heatmap(corr,
vmin=-0.16,
vmax=0.3,
center=0,
annot=True,
fmt=".1f",
cbar_kws={"shrink": 0.5, 'ticks': [-0.08, 0.00, 0.08, 0.16, 0.24]})

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

``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36`

Challenge: Data Analysis with Python Projects - Medical Data Visualizer

Same issue on my end. Ran for like 10 minutes without anything happening.

maybe something is wrong when I am importing the template but that’s really out of my depth. I even tried to import a brand new one but got stuck in the same infinite loading nix environment.

1 Like

It seems every new template I make would run into the same problem. Guess I have to wait until this issue is resolved.

I am having the same error. Hope it is resolved soon.

repl.it has yet again changed something in their import process that is messing up the imports. We made changes in the last couple of weeks to resolve changes they made recently that also messed up the import process. We will let you know when the issue has been resolved.

3 Likes

Thank you! I really want to get on with the course asap

1 Like

Will there be some sort of notification? I stuck on the same thing too.

So it seems I found a way.

1. Import the boilerplate as you would.

2. The hidden .replit file should be opened by default. if it isn’t, press the three dots icon in the file file section, select show hidden file, open .replit under Config files.
now delete these lines

``````[nix]
channel = "stable-22_05"
``````
1. On the right side above the Console, it would ask you to Configure the Run Command in the .Replit file, enter this: `python main.py` Don’t put quotation marks just the text. Then press done.

2. Close all opened replit tab.

Now if you reopen the tab you should be able to use the big green run button as usual.

Thank you for this. I’ve found it also helped to clone the git repo directly and upload all the files as a new project.

I was unable to get past the first project without some kind of intervention.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.