<jupyter_start><jupyter_text>Obesity Analysis<jupyter_code>import pandas as pd
# Standard plotly imports
from chart_studio.plotly import plot, iplot as py
import plotly.graph_objects as go
from plotly.offline import iplot, init_notebook_mode
import plotly.express as px
# Using plotly + cufflinks in offline mode
import cufflinks
cufflinks.go_offline(connected=True)
init_notebook_mode(connected=True)
obe=pd.read_csv("obesity_cleaned.csv")
obe.head()
indObe=obe[obe["Country"]=="India"]
USAObe=obe[obe["Country"]=="United States of America"]
indObe.drop("Country",axis=1,inplace=True)
USAObe.drop("Country",axis=1,inplace=True)
indObe.drop(indObe.columns[indObe.columns.str.contains('unnamed',case = False)],axis = 1, inplace = True)
USAObe.drop(USAObe.columns[USAObe.columns.str.contains('unnamed',case = False)],axis = 1, inplace = True)

indObe.head()
USAObe.head()
import re
def extract(st):
    reg=re.compile("(.*)(\[.+\]).*")
    return reg.match(st).group(1)
indObe["Obesity"]=indObe["Obesity (%)"].apply(lambda x:extract(x))
USAObe["Obesity"]=USAObe["Obesity (%)"].apply(lambda x:extract(x))
indObe.drop("Obesity (%)",axis=1,inplace=True)
USAObe.drop("Obesity (%)",axis=1,inplace=True)
indObe.reset_index(inplace=True)
indObe.drop(indObe.columns[0],axis=1,inplace=True)
USAObe.reset_index(inplace=True)
USAObe.drop(USAObe.columns[0],axis=1,inplace=True)
indObe.head(2)
USAObe.head(3)
ind=indObe.set_index(['Year', 'Sex'])
usa=USAObe.set_index(['Year', 'Sex'])
ind.head(5)
usa.head(5)
ind['Obesity'] = ind['Obesity'].astype(float)
usa['Obesity'] = usa['Obesity'].astype(float)
joined=ind.join(usa, lsuffix=' in India', rsuffix=' in USA')
resetCols=joined.reset_index()
joined.head()
from plotly.subplots import make_subplots

fig = make_subplots(rows=1, cols=2)

fig.add_trace(
    px.line(resetCols, x="Year", y="Obesity in India", color="Sex").data[0],
    row=1, col=1
)

fig.add_trace(
    px.line(resetCols, x="Year", y="Obesity in USA", color="Sex").data[0],
    row=1, col=2
)
fig.update_layout(height=600, width=800, title_text="Side By Side Subplots")
fig.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1819905213270142, 'fraction_numerical': 0.013744075829383886, 'mean_word_length': 7.982978723404256, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '48810', 'license': 'MIT', 'n_tokens_mistral': 867, 'n_tokens_neox': 825, 'n_words': 133, 'path': 'Obesity-India-USA/Obesity_Data_IndiavsUSA.ipynb', 'repo_name': 'SrivastavaSrijan/Data-Analytics-Viz-Projects', 'size': '2110'}