Repl.it doesn’t seem to run. It starts then nothing happens for ages and it says it is running. I also can’t get it to print a chart. I thought my code was wrong, so I copied someone else’s that was complete and working to try that to see if it is the code or not. It still didn’t work.
I don’t know what to do. I had this issue with the calculator too. I wrote it in PyCharm and it worked perfectly, but I had major issues with Repl.it. It’s really dishartening. I stopped for weeks because of it and I’ve only started again.
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 'overweight' column
df['overweight'] = df['weight']/np.square((df['height'])/100).astype(int)
#assign 1 to >25 values and 0 to rest
df['overweight'] = df['overweight'].apply(lambda x : 1 if x > 25 else 0)
# Normalize data by making 0 always good and 1 always bad. If the value of 'cholestorol' or 'gluc' is 1, make the value 0. If the value is more than 1, make the value 1.
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)
# 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(df, id_vars=['cardio'], 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 collumns for the catplot to work correctly.
#group by cardio and count each feature
#df_cat =
# Draw the catplot with 'sns.catplot()'
sns.catplot(data=df_cat, kind='count', x='variable', hue='value', col='cardio')
# 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 = None
# Calculate the correlation matrix
corr = None
# Generate a mask for the upper triangle
mask = None
# Set up the matplotlib figure
fig, ax = None
# Draw the heatmap with 'sns.heatmap()'
# Do not modify the next two lines
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/88.0.4324.190 Safari/537.36.
Challenge: Medical Data Visualizer
Link to the challenge:
and your user name is perfect for me right now, I’m literally losing mine over this haha :’)