Error in medical data visualizer

Tell us what’s happening:
Help me I am getting this unknown error
 python
Matplotlib created a temporary config/cache directory at /tmp/matplotlib-_pzj79ce because the default path (/config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.
Traceback (most recent call last):
File “”, line 7, in
File “/home/runner/boilerplate-medical-data-visualizer-4/”, line 64, in draw_heat_map
sns.heatmap(df_heat,linewidths=.5,annot=True,fmt=’.1f’,mask=mask,square=True,center=0,vmin=-0.08,vmax=0.24,cbar_kws={‘shrink’:.45,‘format’: ‘%.2f’}
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/seaborn/”, line 46, in inner_f
return f(**kwargs)
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/seaborn/”, line 545, in heatmap
plotter = _HeatMapper(data, vmin, vmax, cmap, center, robust, annot, fmt,
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/seaborn/”, line 112, in init
mask = _matrix_mask(data, mask)
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/seaborn/”, line 91, in _matrix_mask
mask = mask | pd.isnull(data)
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/pandas/core/ops/”, line 647, in f
self, other = _align_method_FRAME(self, other, axis, flex=True, level=level)
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/pandas/core/ops/”, line 503, in _align_method_FRAME
right = to_series(right)
File “/opt/virtualenvs/python3/lib/python3.8/site-packages/pandas/core/ops/”, line 465, in to_series
raise ValueError(
ValueError: Unable to coerce to Series, length must be 14: given 2
exit status 1

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

bmi = (df[‘weight’]) / ((df[‘height’] / 100) ** 2)
df[‘overweight’] = [1 if value >25 else 0 for value in bmi]

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’] = [0 if value == 1 else 1 for value in df[‘cholesterol’]]
df[‘gluc’] = [0 if value == 1 else 1 for value in df[‘gluc’]]

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(
‘active’, ‘alco’, ‘cholesterol’, ‘gluc’, ‘overweight’, ‘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 collumns for the catplot to work correctly.
df_cat = df_cat.groupby(['cardio', 'variable', 'value']).size().rename('total').reset_index()

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

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

fig = cat_plot.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_indices_from(np.ones_like(corr))

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

# Draw the heatmap with 'sns.heatmap()'
sns.heatmap(df_heat,linewidths=.5,annot=True,fmt='.1f',mask=mask,square=True,center=0,vmin=-0.08,vmax=0.24,cbar_kws={'shrink':.45,'format': '%.2f'}

# Do not modify the next two lines
return fig

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:83.0) Gecko/20100101 Firefox/83.0.

Challenge: Page View Time Series Visualizer

Link to the challenge: