# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Report on US-Healthcare Databas with Stastistical Analysis 

# + [markdown] _cell_guid="e517f1f3-b54e-4af4-bcca-a2cf6362760c" _uuid="03f9ed9a25f2361725c70bc7e79b3c20c1689c7c"
# Health searches data contains the statistics of google searches made in US. 
# To start our analysis, let's read the data into a pandas dataframe and also we look at the first 3 rows to understand the columns/data. 

# + _cell_guid="9230bd00-6365-4b1a-bea1-b4f8fef5ec93" _uuid="e2105e85a340f0500e1722e35624a11db0e0b442"
import numpy as np
import pandas as pd
from IPython.display import display
import matplotlib.pyplot as plt

# %matplotlib inline

healthSearchData=pd.read_csv("RegionalInterestByConditionOverTime.csv")
healthSearchData.head(3)

# + [markdown] _cell_guid="d92bbc78-8c7d-401e-961a-57153a79274a" _uuid="3f49954ecf067b4f8060a7e294a228906fed604f"
# For our study, we do not consider the "geoCode" column and lets drop it. This is because we already have the city name in a separate column and I would like to keep the data simple.

# + _cell_guid="7c5172ff-6662-42cb-9300-e3bb3ec650f4" _uuid="755c3f945607176620eca2ee6afd14c8a04d14d4"
healthSearchData = healthSearchData.drop(['geoCode'],axis=1)

# + [markdown] _cell_guid="43a39db6-4895-4481-b0b6-23122280258c" _uuid="8e90b2b61d4b35eeeb663eaa7e337425fa7fb848"
# In the dataset, we have 9 medical conditions and the search data is from 2004 to 2017. Its soo refreshing to see data for more than 10 years. Anyway, now we plot year wise search change for the diseases available. 

# + _cell_guid="2175a00c-0c89-4797-a6ee-a7c74f4cd479" _uuid="79f8474948ed02af9ddc2f5d3a0ac5fdf8e52c5b"
#2004-2017
#cancer cardiovascular stroke depression rehab vaccine diarrhea obesity diabetes
yearWiseMeam = {}
for col in healthSearchData.columns:
    if '+' in col:
        year = col.split('+')[0]
        disease = col.split('+')[-1]
        if not disease in yearWiseMeam:
            yearWiseMeam[disease] = {}
        if not year in yearWiseMeam[disease]:
            yearWiseMeam[disease][year] = np.mean(list(healthSearchData[col]))

plt.figure(figsize=(18, 6))
ax = plt.subplot(111)
plt.title("Year wise google medical search", fontsize=20)

ax.set_xticks([0,1,2,3,4,5,6,7,8,9,10,11,12,13])
ax.set_xticklabels(list(yearWiseMeam['cancer'].keys()))
lh = {}
for disease in yearWiseMeam:
    lh[disease] = plt.plot(yearWiseMeam[disease].values())
plt.legend(lh, loc='best')


# + [markdown] _cell_guid="cdef5293-7849-452a-8ff3-2de46bf7f7b2" _uuid="3abc5679d2a220bb6fd3451a3f01e95f41c318a1"
# It can be observed that the line plot has so many uneven jumps. Let's smooth the plot and visualise how the search looks like. This is just for observational benefits and need not be performed everytime.

# + _cell_guid="57a49b99-cbe3-444c-8357-17fd66e38b95" _uuid="be6453fc2b0fb7120bacbbe540ec712287c73c77"
plt.figure(figsize=(18, 6))
ax = plt.subplot(111)
plt.title("Year wise google medical search [smoothened]", fontsize=20)

ax.set_xticks([0,1,2,3,4,5,6,7,8,9,10,11,12,13])
ax.set_xticklabels(list(yearWiseMeam['cancer'].keys()))
lh = {}
myLambda = 0.7
for disease in yearWiseMeam:
    tempList = list(yearWiseMeam[disease].values())
    localMean = np.mean(tempList)
    smoothList = []
    for x in tempList:
        smoothList.append(x + myLambda * (localMean - x)) 
    lh[disease] = plt.plot(smoothList)
plt.legend(lh, loc='best')

# + [markdown] _cell_guid="75f3148f-2729-4d5f-89d6-04cd8d674e7f" _uuid="e80c6af9b23a5b3697253d984bb382d8fdc9b9ab"
# We see that Cancer is the most searched illness whereas cardiovascular search is the least. Surprisingly, in 2017, diabetes is the highest searched illness. I believe that people are becoming more aware about their health and this can mostly be preemptive search to avoid any future illness. Whatever the case, diabetes has overtaken Cancer in search data.
#
#
# -

# # Conclusion
# # It appears what I thought would be seen in the data came out to be true.There has been an increase of search for health issues every year except for one. Also, the region which is considered the “sickest” (South) has the most searches for health issues, while the region considered the “healthiest” (Northeast) has the least searches.



StarcoderdataJupyterScriptsDedupFiltered