<jupyter_start><jupyter_text>The CRISP-DM Methodology will be followed for this project. 1. Business UnderstandingThe COVID-19 pandemic has started spreading across India. To put things in perspective, I decided to analyze data related to the spread of this disease in India. The analysis uses the dataset from the following link: https://www.kaggle.com/sudalairajkumar/covid19-in-india/data The analysis focuses on answering the 3 questions below: 1. Which states have the maximum number of infected people? 2. How do the number of infected people change over time for these states? 3. How did the number of cured vs dead people in each of these states change over time?  2. Data Understanding<jupyter_code># Import Required Libraries
import pandas
import matplotlib.pyplot as plt
import datetime
import matplotlib.dates as mdates
# Load the dataset
daily = pandas.read_csv('dataset/covid_19_india.csv')
daily.head()
daily.tail()<jupyter_output><empty_output><jupyter_text>3. Data Preparation<jupyter_code># Drop Columns with missing data
daily = daily.dropna()
daily.tail() #No missing data

# Drop Unwanted Columnns
daily.drop(['Sno', 'ConfirmedIndianNational', 'ConfirmedForeignNational'], axis = 1)<jupyter_output><empty_output><jupyter_text>4. Answering Questions from Data   Q1. Which states have the maximum number of infected people?<jupyter_code># Get the number of infected people in the Top 5 Infected States 

slist = []
state = []
st_metric = []
case = []
i = 2
while(len(state) != 5):
    keys = daily['ConfirmedTotal'].nlargest(i).keys()
    for index in keys:
        if daily['State/UnionTerritory'][index] not in slist:
            state.append(daily['State/UnionTerritory'][index])
            case.append(daily['ConfirmedTotal'][index])
            slist.append(daily['State/UnionTerritory'][index])
    i += 1
plt.xlabel('State')
plt.ylabel('Number of Cases of Covid-19')
plt.title('Top 5 States with Covid-19 Cases')
plt.bar(state, case)<jupyter_output><empty_output><jupyter_text>From the above bar plot, it can be concluded that Maharashtra has the maximum number of cases (128), followed by Kerala (118), then Karnataka (55), then Telengana (44) and finally Gujarat (43)  Q2. How do the number of infected people change over time for these states?<jupyter_code>date_set_ke = set({})
date_ax_ke = []
val_ax_ke = []
for i in range(392):
    if daily.loc[i]['State/UnionTerritory'] == 'Kerala' and daily.loc[i]['Date'] not in date_set_ke:
        date_ax_ke.append(daily.loc[i]['Date'])
        val_ax_ke.append(daily.loc[i]['ConfirmedTotal'])
        date_set_ke.add(daily.loc[i]['Date'])
for i in range(int(len(date_ax_ke)/2)):
    del(date_ax_ke[i])
    del(val_ax_ke[i])    
for i in range(len(date_ax_ke)):
    date_ax_ke[i] = datetime.date(2020, int(date_ax_ke[i].split('-')[1]), int(date_ax_ke[i].split('-')[0]))  
fig, ax = plt.subplots(1, 1, figsize = (25, 5))
plt.xlabel('Date')
plt.ylabel('Number of Cases of Covid-19')
plt.title('Increase in Cases of Covid-19 in Kerala')
ax.plot(date_ax_ke, val_ax_ke)<jupyter_output><empty_output><jupyter_text>From the above graph, it can be concluded that a sharp rise in the number of cases was observed in Kerala after 15th March 2020<jupyter_code>date_set_ma = set({})
date_ax_ma = []
val_ax_ma = []
for i in range(392):
    if daily.loc[i]['State/UnionTerritory'] == 'Maharashtra' and daily.loc[i]['Date'] not in date_set_ma:
        date_ax_ma.append(daily.loc[i]['Date'])
        val_ax_ma.append(daily.loc[i]['ConfirmedTotal'])
        date_set_ma.add(daily.loc[i]['Date'])
for i in range(int(len(date_ax_ma)/2)):
    del(date_ax_ma[i + 1])
    del(val_ax_ma[i + 1])    
for i in range(len(date_ax_ma)):
    date_ax_ma[i] = datetime.date(2020, int(date_ax_ma[i].split('-')[1]), int(date_ax_ma[i].split('-')[0]))  
fig, ax = plt.subplots(1, 1, figsize = (25, 5))
plt.xlabel('Date')
plt.ylabel('Number of Cases of Covid-19')
plt.title('Increase in Cases of Covid-19 in Maharashtra')
ax.plot(date_ax_ma, val_ax_ma)<jupyter_output><empty_output><jupyter_text>From the above graph, it can be seen that the number of cases steadily increased from 15th March followed by a sudden increase from 23rd March 2020<jupyter_code>import datetime
date_set_ka = set({})
date_ax_ka = []
val_ax_ka = []
for i in range(392):
    if daily.loc[i]['State/UnionTerritory'] == 'Karnataka' and daily.loc[i]['Date'] not in date_set_ka:
        date_ax_ka.append(daily.loc[i]['Date'])
        val_ax_ka.append(daily.loc[i]['ConfirmedTotal'])
        date_set_ka.add(daily.loc[i]['Date'])
for i in range(int(len(date_ax_ka)/2)):
    del(date_ax_ka[i + 1])
    del(val_ax_ka[i + 1])    
for i in range(len(date_ax_ka)):
    date_ax_ka[i] = datetime.date(2020, int(date_ax_ka[i].split('-')[1]), int(date_ax_ka[i].split('-')[0]))  
fig, ax = plt.subplots(1, 1, figsize = (25, 5))
plt.xlabel('Date')
plt.ylabel('Number of Cases of Covid-19')
plt.title('Increase in Cases of Covid-19 in KarnatakaFrom the above graph, it can be concluded that a sharp rise in the number of cases was after 15th March 2020')
ax.plot(date_ax_ka, val_ax_ka)<jupyter_output><empty_output><jupyter_text>From the above graph, it can be concluded that Karnataka has witnessed a steady rate of increase in the number of patients till 21st March, after which the number of cases almost doubled<jupyter_code>date_set_gu = set({})
date_ax_gu = []
val_ax_gu = []
for i in range(392):
    if daily.loc[i]['State/UnionTerritory'] == 'Gujarat' and daily.loc[i]['Date'] not in date_set_gu:
        date_ax_gu.append(daily.loc[i]['Date'])
        val_ax_gu.append(daily.loc[i]['ConfirmedTotal'])
        date_set_gu.add(daily.loc[i]['Date'])
for i in range(int(len(date_ax_gu)/2)):
    del(date_ax_gu[i + 1])
    del(val_ax_gu[i + 1])    
for i in range(len(date_ax_gu)):
    date_ax_gu[i] = datetime.date(2020, int(date_ax_gu[i].split('-')[1]), int(date_ax_gu[i].split('-')[0]))  
fig, ax = plt.subplots(1, 1, figsize = (25, 5))
plt.xlabel('Date')
plt.ylabel('Number of Cases of Covid-19')
plt.title('Increase in Cases of Covid-19 in GujaratFrom the above graph, it can be concluded that a sharp rise in the number of cases was after 15th March 2020')
ax.plot(date_ax_gu, val_ax_gu)<jupyter_output><empty_output><jupyter_text>From the above graph, it can be concluded that given the limited data available, Gujarat saw a steady rise in the number of patients<jupyter_code>date_set_te = set({})
date_ax_te = []
val_ax_te = []
for i in range(392):
    if daily.loc[i]['State/UnionTerritory'] == 'Telengana' and daily.loc[i]['Date'] not in date_set_te:
        date_ax_te.append(daily.loc[i]['Date'])
        val_ax_te.append(daily.loc[i]['ConfirmedTotal'])
        date_set_te.add(daily.loc[i]['Date'])
for i in range(int(len(date_ax_te)/2)):
    del(date_ax_te[i + 1])
    del(val_ax_te[i + 1])    
for i in range(len(date_ax_te)):
    date_ax_te[i] = datetime.date(2020, int(date_ax_te[i].split('-')[1]), int(date_ax_te[i].split('-')[0]))  
fig, ax = plt.subplots(1, 1, figsize = (25, 5))
From the above graph, it can be concluded that a sharp rise in the number of cases was after 15th March 2020
ax.plot(date_ax_te, val_ax_te)<jupyter_output><empty_output><jupyter_text>From the above graph, it can be concluded that Telangana witnessed a sudden rise in the number of cases after 17th March 2020, almost doubling every two days<jupyter_code># How do the rates compare to each other?

fig, ax = plt.subplots(1, 1, figsize = (25, 5))
ax.plot(date_ax_ma, val_ax_ma)
ax.plot(date_ax_ke, val_ax_ke)
ax.plot(date_ax_ka, val_ax_ka)
ax.plot(date_ax_te, val_ax_te)
ax.plot(date_ax_gu, val_ax_gu)
plt.xlabel('Date')
plt.ylabel('Number of Cases of Covid-19')
plt.title('Increase in Cases of Covid-19 in the Top 5 Infected States')
ax.legend(('Maharashtra', 'Kerala', 'Karnataka', 'Telengana', 'Gujarat'))<jupyter_output><empty_output><jupyter_text>From the above comparison, it can be seen that Maharashtra has witnessed the most drastic increase in the number of cases<jupyter_code># Cured vs Dead Telengana
date_set_te = set({})
date_ax_te = []
val_ax_c_te = []
val_ax_d_te = []
for i in range(392):
    if daily.loc[i]['State/UnionTerritory'] == 'Telengana' and daily.loc[i]['Date'] not in date_set_te:
        date_ax_te.append(daily.loc[i]['Date'])
        val_ax_c_te.append(daily.loc[i]['Cured'])
        date_set_te.add(daily.loc[i]['Date'])
        val_ax_d_te.append(daily.loc[i]['Deaths'])
for i in range(int(len(date_ax_te)/2)):
    del(date_ax_te[i + 1])
    del(val_ax_c_te[i + 1])
    del(val_ax_d_te[i + 1])    

for i in range(len(date_ax_te)):
    date_ax_te[i] = datetime.date(2020, int(date_ax_te[i].split('-')[1]), int(date_ax_te[i].split('-')[0]))  
fig, ax = plt.subplots(1, 1, figsize = (25, 5))
plt.xlabel('Date')
plt.ylabel('Number of Patients')
plt.title('Comparison of Cured and Dead Covid-19 Patients in Telengana')
ax.plot(date_ax_te, val_ax_c_te)
ax.plot(date_ax_te, val_ax_d_te)
ax.legend(('Cured', 'Dead'))<jupyter_output><empty_output><jupyter_text>One person was cured while there were no fatalities<jupyter_code># Cured vs Dead Maharashtra
dama_set_ma = set({})
dama_ax_ma = []
val_ax_c_ma = []
val_ax_d_ma = []
for i in range(392):
    if daily.loc[i]['State/UnionTerritory'] == 'Maharashtra' and daily.loc[i]['Date'] not in dama_set_ma:
        dama_ax_ma.append(daily.loc[i]['Date'])
        val_ax_c_ma.append(daily.loc[i]['Cured'])
        dama_set_ma.add(daily.loc[i]['Date'])
        val_ax_d_ma.append(daily.loc[i]['Deaths'])
for i in range(int(len(dama_ax_ma)/2)):
    del(dama_ax_ma[i + 1])
    del(val_ax_c_ma[i + 1])
    del(val_ax_d_ma[i + 1])    

for i in range(len(dama_ax_ma)):
    dama_ax_ma[i] = datetime.date(2020, int(dama_ax_ma[i].split('-')[1]), int(dama_ax_ma[i].split('-')[0]))  
fig, ax = plt.subplots(1, 1, figsize = (25, 5))
plt.xlabel('Date')
plt.ylabel('Number of Patients')
plt.title('Comparison of Cured and Dead Covid-19 Patients in Maharashtra')
ax.plot(dama_ax_ma, val_ax_c_ma)
ax.plot(dama_ax_ma, val_ax_d_ma)
ax.legend(('Cured', 'Dead'))<jupyter_output><empty_output><jupyter_text>3 People are dead while one person has been cured<jupyter_code># Cured vs Dead Kerala
dake_set_ke = set({})
dake_ax_ke = []
val_ax_c_ke = []
val_ax_d_ke = []
for i in range(392):
    if daily.loc[i]['State/UnionTerritory'] == 'Kerala' and daily.loc[i]['Date'] not in dake_set_ke:
        dake_ax_ke.append(daily.loc[i]['Date'])
        val_ax_c_ke.append(daily.loc[i]['Cured'])
        dake_set_ke.add(daily.loc[i]['Date'])
        val_ax_d_ke.append(daily.loc[i]['Deaths'])
for i in range(int(len(dake_ax_ke)/2)):
    del(dake_ax_ke[i + 1])
    del(val_ax_c_ke[i + 1])
    del(val_ax_d_ke[i + 1])    

for i in range(len(dake_ax_ke)):
    dake_ax_ke[i] = datetime.date(2020, int(dake_ax_ke[i].split('-')[1]), int(dake_ax_ke[i].split('-')[0]))  
fig, ax = plt.subplots(1, 1, figsize = (25, 5))
plt.xlabel('Date')
plt.ylabel('Number of Patients')
plt.title('Comparison of Cured and Dead Covid-19 Patients in Kerala')
ax.plot(dake_ax_ke, val_ax_c_ke)
ax.plot(dake_ax_ke, val_ax_d_ke)
ax.legend(('Cured', 'Dead'))<jupyter_output><empty_output><jupyter_text>6 people were cured in Kerala, while there are no fatalities<jupyter_code># Cured vs Dead Gujarat
dagu_set_gu = set({})
dagu_ax_gu = []
val_ax_c_gu = []
val_ax_d_gu = []
for i in range(392):
    if daily.loc[i]['State/UnionTerritory'] == 'Gujarat' and daily.loc[i]['Date'] not in dagu_set_gu:
        dagu_ax_gu.append(daily.loc[i]['Date'])
        val_ax_c_gu.append(daily.loc[i]['Cured'])
        dagu_set_gu.add(daily.loc[i]['Date'])
        val_ax_d_gu.append(daily.loc[i]['Deaths'])
for i in range(int(len(dagu_ax_gu)/2)):
    del(dagu_ax_gu[i + 1])
    del(val_ax_c_gu[i + 1])
    del(val_ax_d_gu[i + 1])    

for i in range(len(dagu_ax_gu)):
    dagu_ax_gu[i] = datetime.date(2020, int(dagu_ax_gu[i].split('-')[1]), int(dagu_ax_gu[i].split('-')[0]))  
fig, ax = plt.subplots(1, 1, figsize = (25, 5))
plt.xlabel('Date')
plt.ylabel('Number of Patients')
plt.title('Comparison of Cured and Dead Covid-19 Patients in Gujarat')
ax.plot(dagu_ax_gu, val_ax_c_gu)
ax.plot(dagu_ax_gu, val_ax_d_gu)
ax.legend(('Cured', 'Dead'))<jupyter_output><empty_output><jupyter_text>3 people have died in Kerala, whereas none have been reported as cured yet<jupyter_code># Cured vs Dead Karnataka
daka_set_ka = set({})
daka_ax_ka = []
val_ax_c_ka = []
val_ax_d_ka = []

for i in range(392):
    if daily.loc[i]['State/UnionTerritory'] == 'Karnataka' and daily.loc[i]['Date'] not in daka_set_ka:
        daka_ax_ka.append(daily.loc[i]['Date'])
        val_ax_c_ka.append(daily.loc[i]['Cured'])
        daka_set_ka.add(daily.loc[i]['Date'])
        val_ax_d_ka.append(daily.loc[i]['Deaths'])
for i in range(int(len(daka_ax_ka)/2)):
    del(daka_ax_ka[i + 1])
    del(val_ax_c_ka[i + 1])
    del(val_ax_d_ka[i + 1])    

for i in range(len(daka_ax_ka)):
    daka_ax_ka[i] = datetime.date(2020, int(daka_ax_ka[i].split('-')[1]), int(daka_ax_ka[i].split('-')[0]))  
fig, ax = plt.subplots(1, 1, figsize = (25, 5))
plt.xlabel('Date')
plt.ylabel('Number of Patients')
plt.title('Comparison of Cured and Dead Covid-19 Patients in Karnataka')
ax.plot(daka_ax_ka, val_ax_c_ka)
ax.plot(daka_ax_ka, val_ax_d_ka)
ax.legend(('Cured', 'Dead'))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15314975480950585, 'fraction_numerical': 0.02187853640135798, 'mean_word_length': 5.0529680365296805, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 57, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '14', 'dir': 'jupyter-structured-clean-dedup', 'id': '109918', 'license': 'CC0-1.0', 'n_tokens_mistral': 5484, 'n_tokens_neox': 5122, 'n_words': 1169, 'path': 'covid19.ipynb', 'repo_name': 'divyanshusharma1709/Blog_Data_Science', 'size': '13255'}