Replit code execution

Question: why is replit not executing my code? I ran the same code in jupyter notebook and Chatgpt, they have all executed the code postively.
Repl link/Link to where the bug appears:

**Screenshots, links, or other helpful context:


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')
#Calculate the BMI
df['BMI'] = df['weight'] / (df['height'] /100)**2
# Add 'overweight' column
df['overweight'] = df['BMI'].apply(lambda x:1 if x >25 else 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['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 = pd.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 columns for the catplot to work correctly.
    df_cat = df_cat.rename(columns={'variable':'feature', 'value':'count'})
    # Draw the catplot with 'sns.catplot()'
    g = sns.catplot( 
    data = df_cat,
    x ='feature',
    hue = 'count',
    col = 'cardio',
    kind = 'count',
    height =5,
    aspect = 1.5
    # Get the figure for the output
    fig = g.fig

    # Do not modify the next two lines
    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(np.ones_like(corr, dtype=bool))

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

    # Draw the heatmap with 'sns.heatmap()'
             annot = True,
             cmap = 'coolwarm',
             mask = mask,
             ax =ax)

    # Do not modify the next two lines
    return fig

# Call the function to generate the catplot 

# Call the function to generate the heatmap

Did AI generate the code? If so it’s sometimes (if not most times) wrong. Please make sure that the code is real/should actually work as it may not be a problem with replit.


No I actually did workout every bit of it…

Hey @Mchongan!

Can you try running your code using our Python Data Science template? It has some extra configuration that might fix the error you’re having. If you are still seeing issues, can you please share the full error you get?

1 Like