Tell us what’s happening:
Hi, when i run the project i get the follwing error:
/home/runner/boilerplate-medical-data-visualizer/.pythonlibs/lib/python3.10/site-packages/seaborn/_oldcore.py:1498: FutureWarning: is_categorical_dtype is deprecated and will be removed in a future version. Use isinstance(dtype, CategoricalDtype) instead
if pd.api.types.is_categorical_dtype(vector):
Traceback (most recent call last):
TypeError: cannot unpack non-iterable NoneType object
my question is about the future warning message. Do i have to update something to get rid of this error?
Your code so far
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
overweigh_column = []
overweight_column_temp = df["weight"] / ((df["height"] / 100)**2)
for element in overweight_column_temp:
if element > 25:
overweigh_column.append(1)
else:
overweigh_column.append(0)
df['overweight'] = overweigh_column
# 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.
cholesterol_list = list(df["cholesterol"])
for count, element in enumerate(cholesterol_list):
if element == 1:
cholesterol_list[count] = 0
elif element > 1:
cholesterol_list[count] = 1
df["cholesterol"] = cholesterol_list
gluc_list = list(df["gluc"])
for count, element in enumerate(gluc_list):
if element == 1:
gluc_list[count] = 0
elif element > 1:
gluc_list[count] = 1
df["gluc"] = gluc_list
# 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", "alco", "active", "smoke"])
# 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 = None
# Draw the catplot with 'sns.catplot()'
# Get the figure for the output
fig = sns.catplot()
# 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
Thank you
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36
Challenge: Data Analysis with Python Projects - Medical Data Visualizer
Link to the challenge: