<jupyter_start><jupyter_text>Enter the name of the country that you are intersted in.<jupyter_code>country = 'egypt'
country = country.capitalize()<jupyter_output><empty_output><jupyter_text>Now we import our data from https://github.com/CSSEGISandData/COVID-19 Each data is imported separtly from its link<jupyter_code>cases = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv')
deaths = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_deaths_global.csv')
recoverd = pd.read_csv('https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_recovered_global.csv')<jupyter_output><empty_output><jupyter_text>Now we drop unwanted columns then transpose our data from several columns to two roes to be easily handled then reset index and rename the new columns names<jupyter_code>cases = cases[cases['Country/Region'] == country].drop(['Province/State', 'Lat', 'Long', 'Country/Region'], 1).transpose()
cases = cases.reset_index()
cases = cases.rename(columns={cases.columns[0]:'date', cases.columns[1]:'number_of_cases'})
cases
deaths = deaths[deaths['Country/Region'] == country].drop(['Province/State', 'Lat', 'Long', 'Country/Region'], 1).transpose()
deaths = deaths.reset_index()
deaths = deaths.rename(columns={deaths.columns[0]:'date', deaths.columns[1]:'number_of_deaths'})
deaths
recoverd = recoverd[recoverd['Country/Region'] == country].drop(['Province/State', 'Lat', 'Long', 'Country/Region'], 1).transpose()
recoverd = recoverd.reset_index()
recoverd = recoverd.rename(columns={recoverd.columns[0]:'date', recoverd.columns[1]:'number_of_recoverd'})
recoverd<jupyter_output><empty_output><jupyter_text>Now we combine the three data frames in one and the change the type of date column from string to datatime<jupyter_code>covid_data = pd.concat([cases, deaths['number_of_deaths'], recoverd['number_of_recoverd']], 1)
covid_data['date'] = pd.to_datetime(covid_data['date'])<jupyter_output><empty_output><jupyter_text>Data collected is add to the previous day, so will calculate the diff between every row to get the data for every single day alone.<jupyter_code>every_day_data = covid_data[['number_of_cases', 'number_of_deaths', 'number_of_recoverd']].diff().dropna()
every_day_data = pd.concat([covid_data['date'], every_day_data], 1)<jupyter_output><empty_output><jupyter_text>Visualize the final data table we got that contain data after curing<jupyter_code>every_day_data.dropna(inplace=True)
every_day_data<jupyter_output><empty_output><jupyter_text>Data analysis for Covid-19 cases<jupyter_code>f"The total sum of all cases in {country} is {np.sum(every_day_data['number_of_cases'])} till date {every_day_data.iloc[-1, 0]}"
#Detremine the day with the highest number of infections
case_peak_day = every_day_data.loc[every_day_data['number_of_cases'] == np.max(every_day_data['number_of_cases']), 'date'].to_string().split()[1]
case_peak_day
#Detremine the month that has the day with the highest number on infections, so it may be the peak month.
month_of_case_peak_day= int(case_peak_day.split('-')[1])
month_of_case_peak_day
f"The max number of infections occured per day was {np.max(every_day_data['number_of_cases'])} which occured on date {case_peak_day}"
# Plotting number of cases per day

fig, ax = plt.subplots(figsize=(9,5))
ax.plot(
    every_day_data['date'],
    every_day_data['number_of_cases'],
     label='Numbers of Covid-19 cases'
)
ax.set(xlabel="Date",
       ylabel="Number of cases per day",
       title=f"Covid-19 cases in {country} till date {every_day_data.iloc[-1, 0]}")
ax.axvline(pd.Timestamp(case_peak_day), color='r', label= f'The Day with highest cases number in {country}\n{case_peak_day}')
ax.legend()
plt.setp(ax.get_xticklabels(), rotation=45)
plt.grid()
plt.show()<jupyter_output><empty_output><jupyter_text>Data analysis for Covid-19 deaths<jupyter_code>f"The total sum of all deaths in {country} is {np.sum(every_day_data['number_of_deaths'])} till date {every_day_data.iloc[-1, 0]}"
#Detremine the day with the highest number of deaths
death_peak_day = every_day_data.loc[every_day_data['number_of_deaths'] == np.max(every_day_data['number_of_deaths']), 'date'].to_string().split()[1]
death_peak_day
#Detremine the month that has the day with the highest number of deaths.
month_of_death_peak_day= int(death_peak_day.split('-')[1])
month_of_death_peak_day
f"The max number of deaths occured per day was {np.max(every_day_data['number_of_deaths'])} which occured on date {death_peak_day}"
# Plotting number of deaths per day

fig, ax = plt.subplots(figsize=(9,5))
ax.plot(
    every_day_data['date'],
    every_day_data['number_of_deaths'],
     label='Numbers of Covid-19 deaths'
)
ax.set(xlabel="Date",
       ylabel="Number of deaths per day",
       title=f"Covid-19 deaths in {country} till date {every_day_data.iloc[-1, 0]}")
ax.axvline(pd.Timestamp(death_peak_day), color='r', label= f'The day with highest death number in {country}\n{death_peak_day}')
ax.legend()
plt.setp(ax.get_xticklabels(), rotation=45)
plt.grid()
plt.show()<jupyter_output><empty_output><jupyter_text>Data analysis for Covid-19 recovered<jupyter_code>f"The total sum of all recovers in {country} is {np.sum(every_day_data['number_of_recoverd'])} till date {every_day_data.iloc[-1, 0]}"
#Detremine the day with the highest number of deaths
recover_peak_day = every_day_data.loc[every_day_data['number_of_recoverd'] == np.max(every_day_data['number_of_recoverd']), 'date'].to_string().split()[1]
recover_peak_day
#Detremine the month that has the day with the highest number of deaths.
month_of_recover_peak_day= int(recover_peak_day.split('-')[1])
month_of_recover_peak_day
f"The max number of recoverd occured per day was {np.max(every_day_data['number_of_recoverd'])} which occured on date {recover_peak_day}"
# Plotting number of recoverd per day

fig, ax = plt.subplots(figsize=(9,5))
ax.plot(
    every_day_data['date'],
    every_day_data['number_of_recoverd'],
     label='Numbers of Covid-19 recoverd'
)
ax.set(xlabel="Date",
       ylabel="Number of recoverd per day",
       title=f"Covid-19 recoverd in {country} till date {every_day_data.iloc[-1, 0]}")
ax.axvline(pd.Timestamp(recover_peak_day), color='r', label= f'The day with highest recoverd number in {country}\n{recover_peak_day}')
ax.legend()
plt.setp(ax.get_xticklabels(), rotation=45)
plt.grid()
plt.show()<jupyter_output><empty_output><jupyter_text>Data anlaysis for the month with high infection number, a month before and a month after are also included.<jupyter_code>every_day_data2 = every_day_data
every_day_data2
#Divide data by month in order to get the data of every month separately
months = list(every_day_data2.groupby(pd.Grouper(key='date', freq='M'))) 
data_of_month_of_peak = months[month_of_case_peak_day-1][1]
data_of_month_before_peak = months[month_of_case_peak_day-2][1]
data_of_month_after_peak = months[month_of_case_peak_day][1]
data_of_peak_period_3_months = pd.concat([data_of_month_before_peak,data_of_month_of_peak, data_of_month_after_peak])
data_of_peak_period_3_months
fig, ax = plt.subplots(figsize=(9,5))
ax.plot(
    data_of_peak_period_3_months['date'],
    data_of_peak_period_3_months['number_of_cases']
)
ax.set(xlabel="Date",
       ylabel="Number of cases per day",
       title=f"Covid-19 cases in {country} through peak time months : {month_of_case_peak_day-1}, {month_of_case_peak_day} and {month_of_case_peak_day+1}")
plt.setp(ax.get_xticklabels(), rotation=45)
plt.grid()
plt.show()<jupyter_output><empty_output><jupyter_text>From the previous graph we notice that the cases increased during May to reah its peak through June  to reach high as 1774 case per day and then decliend in July under 400 case per day. (This was the first wave)<jupyter_code>fig, ax = plt.subplots(figsize=(9,5))
ax.plot(
    data_of_peak_period_3_months['date'],
    data_of_peak_period_3_months['number_of_deaths']
)
ax.set(xlabel="Date",
       ylabel="Number of deaths per day",
       title=f"Covid-19 deaths in {country} through peak time months : {month_of_case_peak_day-1}, {month_of_case_peak_day} and {month_of_case_peak_day+1}")
plt.setp(ax.get_xticklabels(), rotation=45)
plt.grid()
plt.show()<jupyter_output><empty_output><jupyter_text>As cases graph deaths number followed the same manner<jupyter_code>fig, ax = plt.subplots(figsize=(9,5))
ax.plot(
    data_of_peak_period_3_months['date'],
    data_of_peak_period_3_months['number_of_recoverd']
)
ax.set(xlabel="Date",
       ylabel="Number of recoverd per day",
       title=f"Covid-19 revocerd in {country} through peak time months : {month_of_case_peak_day-1}, {month_of_case_peak_day} and {month_of_case_peak_day+1}")
plt.setp(ax.get_xticklabels(), rotation=45)
plt.grid()
plt.show()<jupyter_output><empty_output><jupyter_text>percentage of each category<jupyter_code>total_number_of_case = cases.iloc[-1,1]
total_number_of_death = deaths.iloc[-1,1]
total_number_of_recover = recoverd.iloc[-1,1]
number_of_active_cases = total_number_of_case - (total_number_of_death + total_number_of_recover)
fig = plt.figure()
ax = fig.add_axes([0,0,1,1])
ax.axis('equal')
categories = ['number_of_active_cases', 'total_number_of_deaths', 'total_number_of_recoverd']
percent = [number_of_active_cases, total_number_of_death, total_number_of_recover]
ax.pie(percent, labels = categories,autopct='%1.2f%%')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1258850478967097, 'fraction_numerical': 0.014993752603082049, 'mean_word_length': 7.5226264418811, 'pattern_counts': {'":': 0, '<': 53, '<?xml version=': 0, '>': 53, 'https://': 4, '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': '13', 'dir': 'jupyter-structured-clean-dedup', 'id': '625432', 'license': 'MIT', 'n_tokens_mistral': 3635, 'n_tokens_neox': 3470, 'n_words': 704, 'path': 'covid analysis.ipynb', 'repo_name': 'Shalash96/PythonScripts', 'size': '9604'}