text_html_output_1.png
import matplotlib.pyplot as plt

import pandas as pd

import seaborn as sns

hlc_data = pd.read_csv('../input/healthy-lifestyle-cities-report-2021/healthy_lifestyle_city_2021.csv')

hlc_data.columns

cleaned_hlc_data = hlc_data.copy()
cleaned_hlc_data['Obesity levels(Country)'] = cleaned_hlc_data['Obesity levels(Country)'].str.replace('%', '', regex=False)
cleaned_hlc_data['Obesity levels(Country)'] = cleaned_hlc_data['Obesity levels(Country)'].astype(str).astype(float)
cleaned_hlc_data['Cost of a bottle of water(City)'] = cleaned_hlc_data['Cost of a bottle of water(City)'].str.replace('£', '', regex=False)
cleaned_hlc_data['Cost of a bottle of water(City)'] = cleaned_hlc_data['Cost of a bottle of water(City)'].astype(str).astype(float)
cleaned_hlc_data['Cost of a monthly gym membership(City)'] = cleaned_hlc_data['Cost of a monthly gym membership(City)'].str.replace('£', '', regex=False)
cleaned_hlc_data['Cost of a monthly gym membership(City)'] = cleaned_hlc_data['Cost of a monthly gym membership(City)'].astype(str).astype(float)
cleaned_hlc_data.corr()

hours_hlc_data = cleaned_hlc_data.copy()
hours_hlc_data = hours_hlc_data[hours_hlc_data['Annual avg. hours worked'] != '-']
hours_hlc_data['Annual avg. hours worked'] = hours_hlc_data['Annual avg. hours worked'].astype(str).astype(int)
hours_hlc_data.corr()

sun_hlc_data = cleaned_hlc_data.copy()
sun_hlc_data = sun_hlc_data[sun_hlc_data['Sunshine hours(City)'] != '-']
sun_hlc_data['Sunshine hours(City)'] = sun_hlc_data['Sunshine hours(City)'].astype(str).astype(int)
sun_hlc_data.corr()

pol_hlc_data = cleaned_hlc_data.copy()
pol_hlc_data = pol_hlc_data[pol_hlc_data['Pollution(Index score) (City)'] != '-']
pol_hlc_data['Pollution(Index score) (City)'] = pol_hlc_data['Pollution(Index score) (City)'].astype(str).astype(float)
pol_hlc_data.corr()

plt.figure(figsize=(10, 5))
plt.xlabel('Happiness')
plt.ylabel('Annual avg. hours worked')
plt.title('Happiness and Hours Worked Viz')
sns.regplot(data=hours_hlc_data, x='Happiness levels(Country)', y='Annual avg. hours worked')