<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Posts | Saif Sayeed, Syed</title><link>https://saif-sayeed-resume.netlify.app/post/</link><atom:link href="https://saif-sayeed-resume.netlify.app/post/index.xml" rel="self" type="application/rss+xml"/><description>Posts</description><generator>Wowchemy (https://wowchemy.com)</generator><language>en-us</language><image><url>https://saif-sayeed-resume.netlify.app/media/icon_hua2ec155b4296a9c9791d015323e16eb5_11927_512x512_fill_lanczos_center_2.png</url><title>Posts</title><link>https://saif-sayeed-resume.netlify.app/post/</link></image><item><title>Animated Covid 19 analysis using Python</title><link>https://saif-sayeed-resume.netlify.app/post/covid_analysis_python/</link><pubDate>Tue, 20 Jul 2021 00:00:00 +0000</pubDate><guid>https://saif-sayeed-resume.netlify.app/post/covid_analysis_python/</guid><description>&lt;h3 id="covid-19-analysis-using-python">Covid 19 analysis using Python&lt;/h3>
&lt;p>We use Python to animate the spread of covid around the world. Then we focus on a few countries and see how the impact of lockdown has affected the spread of covid in that country. We further see how the infection rates and death rates are correlated.&lt;/p>
&lt;hr>
&lt;h3 id="importing-modules">Importing modules&lt;/h3>
&lt;h3 id="task-1">Task 1&lt;/h3>
&lt;pre>&lt;code class="language-python">import pandas as pd
import numpy as np
import plotly.express as px
import matplotlib.pyplot as plt
print('modules are imported')
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>modules are imported
&lt;/code>&lt;/pre>
&lt;h3 id="task-11">Task 1.1:&lt;/h3>
&lt;h4 id="loading-the-dataset">Loading the Dataset&lt;/h4>
&lt;pre>&lt;code class="language-python">dataset_url = 'https://raw.githubusercontent.com/datasets/covid-19/main/data/countries-aggregated.csv'
fname = 'data/countries-aggregated.csv'
df = pd.read_csv(fname)
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">df_31May21 = df[df.Date == '2020-05-31']
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">df_31May21.head()
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Country&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;th>Recovered&lt;/th>
&lt;th>Deaths&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>130&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>15208&lt;/td>
&lt;td>1328&lt;/td>
&lt;td>258&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>658&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>Albania&lt;/td>
&lt;td>1137&lt;/td>
&lt;td>872&lt;/td>
&lt;td>33&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>1186&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>Algeria&lt;/td>
&lt;td>9394&lt;/td>
&lt;td>5748&lt;/td>
&lt;td>653&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>1714&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>Andorra&lt;/td>
&lt;td>764&lt;/td>
&lt;td>694&lt;/td>
&lt;td>51&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>2242&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>Angola&lt;/td>
&lt;td>86&lt;/td>
&lt;td>18&lt;/td>
&lt;td>4&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;h3 id="task-12">Task 1.2:&lt;/h3>
&lt;h4 id="lets-check-the-dataframe">let&amp;rsquo;s check the dataframe&lt;/h4>
&lt;pre>&lt;code class="language-python">df_31May21.head()
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Country&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;th>Recovered&lt;/th>
&lt;th>Deaths&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>130&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>15208&lt;/td>
&lt;td>1328&lt;/td>
&lt;td>258&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>658&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>Albania&lt;/td>
&lt;td>1137&lt;/td>
&lt;td>872&lt;/td>
&lt;td>33&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>1186&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>Algeria&lt;/td>
&lt;td>9394&lt;/td>
&lt;td>5748&lt;/td>
&lt;td>653&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>1714&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>Andorra&lt;/td>
&lt;td>764&lt;/td>
&lt;td>694&lt;/td>
&lt;td>51&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>2242&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>Angola&lt;/td>
&lt;td>86&lt;/td>
&lt;td>18&lt;/td>
&lt;td>4&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;pre>&lt;code class="language-python">df_31May21.tail()
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Country&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;th>Recovered&lt;/th>
&lt;th>Deaths&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>100450&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>Vietnam&lt;/td>
&lt;td>328&lt;/td>
&lt;td>279&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>100978&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>West Bank and Gaza&lt;/td>
&lt;td>448&lt;/td>
&lt;td>372&lt;/td>
&lt;td>3&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>101506&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>Yemen&lt;/td>
&lt;td>323&lt;/td>
&lt;td>14&lt;/td>
&lt;td>80&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>102034&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>Zambia&lt;/td>
&lt;td>1057&lt;/td>
&lt;td>779&lt;/td>
&lt;td>7&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>102562&lt;/th>
&lt;td>2020-05-31&lt;/td>
&lt;td>Zimbabwe&lt;/td>
&lt;td>178&lt;/td>
&lt;td>29&lt;/td>
&lt;td>4&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;h4 id="lets-check-the-shape-of-the-dataframe">let&amp;rsquo;s check the shape of the dataframe&lt;/h4>
&lt;pre>&lt;code class="language-python">df_31May21.shape
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>(195, 5)
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">df.shape
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>(102960, 5)
&lt;/code>&lt;/pre>
&lt;h3 id="task-21-">Task 2.1 :&lt;/h3>
&lt;h4 id="lets-do-some-preprocessing">let&amp;rsquo;s do some preprocessing&lt;/h4>
&lt;pre>&lt;code class="language-python">dfconf=df[df.Confirmed&amp;gt;0]
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">dfconf.head()
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Country&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;th>Recovered&lt;/th>
&lt;th>Deaths&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>33&lt;/th>
&lt;td>2020-02-24&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>1&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>34&lt;/th>
&lt;td>2020-02-25&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>1&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>35&lt;/th>
&lt;td>2020-02-26&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>1&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>36&lt;/th>
&lt;td>2020-02-27&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>1&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>37&lt;/th>
&lt;td>2020-02-28&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>1&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;pre>&lt;code class="language-python">dfconf.shape
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>(91970, 5)
&lt;/code>&lt;/pre>
&lt;h4 id="lets-see-data-related-to-a-country-for-example-italy">let&amp;rsquo;s see data related to a country for example Italy&lt;/h4>
&lt;pre>&lt;code class="language-python">dfconf[dfconf.Country=='Italy'].head(10)
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Country&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;th>Recovered&lt;/th>
&lt;th>Deaths&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>44889&lt;/th>
&lt;td>2020-01-31&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>2&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44890&lt;/th>
&lt;td>2020-02-01&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>2&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44891&lt;/th>
&lt;td>2020-02-02&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>2&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44892&lt;/th>
&lt;td>2020-02-03&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>2&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44893&lt;/th>
&lt;td>2020-02-04&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>2&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44894&lt;/th>
&lt;td>2020-02-05&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>2&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44895&lt;/th>
&lt;td>2020-02-06&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>2&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44896&lt;/th>
&lt;td>2020-02-07&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>3&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44897&lt;/th>
&lt;td>2020-02-08&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>3&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44898&lt;/th>
&lt;td>2020-02-09&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>3&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;h4 id="lets-see-global-spread-of-covid19">let&amp;rsquo;s see Global spread of Covid19&lt;/h4>
&lt;h2 id="code">Code:&lt;/h2>
&lt;pre>&lt;code class="language-python">fig = px.choropleth(dfconf, locations='Country', locationmode='country names', color='Confirmed', animation_frame='Date')
fig.layout.updatemenus[0].buttons[0].args[1]['frame']['duration'] = 30
fig.layout.updatemenus[0].buttons[0].args[1]['transition']['duration'] = 5
fig.update_geos(projection_type=&amp;quot;equirectangular&amp;quot;, visible=True, resolution=50)
fig.update_layout(
title_text = 'Global Spread of Coronavirus',
title_x = 0.5,
geo=dict(
showframe = False,
showcoastlines = False,
))
#fig.show()
iplot(fig,show_link=False)
pio.write_json(fig,&amp;quot;file001.json&amp;quot;,engine=&amp;quot;json&amp;quot;)
fig.write_html(&amp;quot;plot001.html&amp;quot;)
&lt;/code>&lt;/pre>
&lt;h2 id="chart-1-global-spread-of-covid-over-time">Chart 1: Global Spread of Covid over Time&lt;/h2>
&lt;p>
&lt;figure id="figure-spread-of-covid">
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img alt="spread of covid"
src="https://saif-sayeed-resume.netlify.app/post/covid_analysis_python/data/covidplot002.gif"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;figcaption>
Spread of Covid
&lt;/figcaption>&lt;/figure>
&lt;/p>
&lt;p>Example of Infection rate in China:&lt;/p>
&lt;h1 id="chart-2">Chart 2:&lt;/h1>
&lt;div id="chart-137452986" class="chart">&lt;/div>
&lt;script>
(function() {
let a = setInterval( function() {
if ( typeof window.Plotly === 'undefined' ) {
return;
}
clearInterval( a );
Plotly.d3.json("./ratechina.json", function(chart) {
Plotly.plot('chart-137452986', chart.data, chart.layout, {responsive: true});
});
}, 500 );
})();
&lt;/script>
&lt;!--
&lt;div id="chart-823917465" class="chart">&lt;/div>
&lt;script>
(function() {
let a = setInterval( function() {
if ( typeof window.Plotly === 'undefined' ) {
return;
}
clearInterval( a );
Plotly.d3.json("./file001.json", function(chart) {
Plotly.plot('chart-823917465', chart.data, chart.layout, {responsive: true});
});
}, 500 );
})();
&lt;/script> -->
&lt;!-- &lt;iframe
src="https://github.com/saif-sayeed/resume-demo/blob/master/content/post/covid_analysis_python/ch001.html"
width="90%"
height="500px"
style="border:none;">
&lt;/iframe> -->---
&lt;h4 id="lets-see-global-spread-of-covid19-1">let&amp;rsquo;s see Global spread of Covid19&lt;/h4>
&lt;h2 id="title-chk-part-02">title: Chk Part 02&lt;/h2>
&lt;h3 id="lets-see-global-deaths-of-covid19">Let&amp;rsquo;s see Global deaths of Covid19&lt;/h3>
&lt;pre>&lt;code class="language-python">dfdeaths=df[df.Deaths&amp;gt;0]
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">dfdeaths.head()
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Country&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;th>Recovered&lt;/th>
&lt;th>Deaths&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>60&lt;/th>
&lt;td>2020-03-22&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>34&lt;/td>
&lt;td>1&lt;/td>
&lt;td>1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>61&lt;/th>
&lt;td>2020-03-23&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>41&lt;/td>
&lt;td>1&lt;/td>
&lt;td>1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>62&lt;/th>
&lt;td>2020-03-24&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>43&lt;/td>
&lt;td>1&lt;/td>
&lt;td>1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>63&lt;/th>
&lt;td>2020-03-25&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>76&lt;/td>
&lt;td>2&lt;/td>
&lt;td>2&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>64&lt;/th>
&lt;td>2020-03-26&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>80&lt;/td>
&lt;td>2&lt;/td>
&lt;td>3&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;pre>&lt;code class="language-python">dfdeaths.shape
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>(81987, 5)
&lt;/code>&lt;/pre>
&lt;h2 id="chart-2-global-deaths-from-covid">Chart 2: Global Deaths from Covid&lt;/h2>
&lt;h2 id="title-chk-part-03">
&lt;figure id="figure-global-deaths-from-covid">
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img alt="Global Deaths from Covid"
src="https://saif-sayeed-resume.netlify.app/post/covid_analysis_python/data/gdc4xlowres3.gif"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;figcaption>
Global Deaths from Covid
&lt;/figcaption>&lt;/figure>
title: Chk Part 03&lt;/h2>
&lt;h3 id="lets-visualize-how-intensive-the-covid19-transmission-has-been-in-each-of-the-country">Let&amp;rsquo;s Visualize how intensive the Covid19 Transmission has been in each of the country&lt;/h3>
&lt;p>let&amp;rsquo;s start with an example:&lt;/p>
&lt;pre>&lt;code class="language-python">df_china=df[df.Country == 'China']
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">import pandas as pd
import numpy as np
import plotly.express as px
import matplotlib.pyplot as plt
print('modules are imported')
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>modules are imported
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">df_china.head()
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Country&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;th>Recovered&lt;/th>
&lt;th>Deaths&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>19008&lt;/th>
&lt;td>2020-01-22&lt;/td>
&lt;td>China&lt;/td>
&lt;td>548&lt;/td>
&lt;td>28&lt;/td>
&lt;td>17&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>19009&lt;/th>
&lt;td>2020-01-23&lt;/td>
&lt;td>China&lt;/td>
&lt;td>643&lt;/td>
&lt;td>30&lt;/td>
&lt;td>18&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>19010&lt;/th>
&lt;td>2020-01-24&lt;/td>
&lt;td>China&lt;/td>
&lt;td>920&lt;/td>
&lt;td>36&lt;/td>
&lt;td>26&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>19011&lt;/th>
&lt;td>2020-01-25&lt;/td>
&lt;td>China&lt;/td>
&lt;td>1406&lt;/td>
&lt;td>39&lt;/td>
&lt;td>42&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>19012&lt;/th>
&lt;td>2020-01-26&lt;/td>
&lt;td>China&lt;/td>
&lt;td>2075&lt;/td>
&lt;td>49&lt;/td>
&lt;td>56&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;p>let&amp;rsquo;s select the columns that we need&lt;/p>
&lt;pre>&lt;code class="language-python">df_china=df_china[['Date','Confirmed']]
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">df_china.head()
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>19008&lt;/th>
&lt;td>2020-01-22&lt;/td>
&lt;td>548&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>19009&lt;/th>
&lt;td>2020-01-23&lt;/td>
&lt;td>643&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>19010&lt;/th>
&lt;td>2020-01-24&lt;/td>
&lt;td>920&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>19011&lt;/th>
&lt;td>2020-01-25&lt;/td>
&lt;td>1406&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>19012&lt;/th>
&lt;td>2020-01-26&lt;/td>
&lt;td>2075&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;p>calculating the first derivation of confrimed column&lt;/p>
&lt;pre>&lt;code class="language-python">df_china['Infection Rate']=df_china['Confirmed'].diff()
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">df_china.head()
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;th>Infection Rate&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>19008&lt;/th>
&lt;td>2020-01-22&lt;/td>
&lt;td>548&lt;/td>
&lt;td>NaN&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>19009&lt;/th>
&lt;td>2020-01-23&lt;/td>
&lt;td>643&lt;/td>
&lt;td>95.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>19010&lt;/th>
&lt;td>2020-01-24&lt;/td>
&lt;td>920&lt;/td>
&lt;td>277.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>19011&lt;/th>
&lt;td>2020-01-25&lt;/td>
&lt;td>1406&lt;/td>
&lt;td>486.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>19012&lt;/th>
&lt;td>2020-01-26&lt;/td>
&lt;td>2075&lt;/td>
&lt;td>669.0&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;pre>&lt;code class="language-python">#px.line(df_china, x='Date', y=['Confirmed', 'Infection Rate'])
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">df_china['Infection Rate'].max()
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>15136.0
&lt;/code>&lt;/pre>
&lt;h3 id="task-32">Task 3.2:&lt;/h3>
&lt;h4 id="lets-calculate-maximum-infection-rate-for-all-of-the-countries">Let&amp;rsquo;s Calculate Maximum infection rate for all of the countries&lt;/h4>
&lt;pre>&lt;code class="language-python">df.head()
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Country&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;th>Recovered&lt;/th>
&lt;th>Deaths&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>0&lt;/th>
&lt;td>2020-01-22&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>1&lt;/th>
&lt;td>2020-01-23&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>2&lt;/th>
&lt;td>2020-01-24&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>3&lt;/th>
&lt;td>2020-01-25&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>4&lt;/th>
&lt;td>2020-01-26&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;pre>&lt;code class="language-python">countries=list(df['Country'].unique())
#countries
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">countries=list(df['Country'].unique())
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">max_infection_rate=[]
for c in countries :
MIR = df[df.Country == c].Confirmed.diff().max()
max_infection_rate.append(MIR)
#print(max_infection_rate)
&lt;/code>&lt;/pre>
&lt;h3 id="task-33">Task 3.3:&lt;/h3>
&lt;h4 id="lets-create-a-new-dataframe">let&amp;rsquo;s create a new Dataframe&lt;/h4>
&lt;pre>&lt;code class="language-python">df_MIR=pd.DataFrame()
df_MIR['Country'] = countries
df_MIR['Max Infection Rate'] = max_infection_rate
df_MIR.head()
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Country&lt;/th>
&lt;th>Max Infection Rate&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>0&lt;/th>
&lt;td>Afghanistan&lt;/td>
&lt;td>5168.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>1&lt;/th>
&lt;td>Albania&lt;/td>
&lt;td>1239.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>2&lt;/th>
&lt;td>Algeria&lt;/td>
&lt;td>1133.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>3&lt;/th>
&lt;td>Andorra&lt;/td>
&lt;td>299.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>4&lt;/th>
&lt;td>Angola&lt;/td>
&lt;td>405.0&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;h4 id="lets-plot-the-barchart--maximum-infection-rate-of-each-country">Let&amp;rsquo;s plot the barchart : maximum infection rate of each country&lt;/h4>
&lt;pre>&lt;code class="language-python">#px.bar(df_MIR, x='Country', y='Max Infection Rate', color='Country', title='global maximum infection rate', log_y=True)
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">#log to increase the quALITY FOR low bars - changes scale for y axis
&lt;/code>&lt;/pre>
&lt;h3 id="task-4-lets-see-how-national-lockdowns-impacts-covid19-transmission-in-italy">Task 4: Let&amp;rsquo;s See how National Lockdowns Impacts Covid19 transmission in Italy&lt;/h3>
&lt;h3 id="covid19-pandemic-lockdown-in-italy">COVID19 pandemic lockdown in Italy&lt;/h3>
&lt;p>On 9 March 2020, the government of Italy under Prime Minister Giuseppe Conte imposed a national quarantine, restricting the movement of the population except for necessity, work, and health circumstances, in response to the growing pandemic of COVID-19 in the country. &lt;a href="https://en.wikipedia.org/wiki/COVID-19_pandemic_lockdown_in_Italy#:~:text=On%209%20March%202020%2C%20the,COVID%2D19%20in%20the%20country.">source&lt;/a>&lt;/p>
&lt;pre>&lt;code class="language-python">italy_lockdown_start_date = '2020-03-09'
italy_lockdown_a_month_later = '2020-04-09'
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">df.head()
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Country&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;th>Recovered&lt;/th>
&lt;th>Deaths&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>0&lt;/th>
&lt;td>2020-01-22&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>1&lt;/th>
&lt;td>2020-01-23&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>2&lt;/th>
&lt;td>2020-01-24&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>3&lt;/th>
&lt;td>2020-01-25&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>4&lt;/th>
&lt;td>2020-01-26&lt;/td>
&lt;td>Afghanistan&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;p>let&amp;rsquo;s get data related to italy&lt;/p>
&lt;pre>&lt;code class="language-python">df_italy=df[df.Country=='Italy']
&lt;/code>&lt;/pre>
&lt;p>lets check the dataframe&lt;/p>
&lt;pre>&lt;code class="language-python">df_italy.head()
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Country&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;th>Recovered&lt;/th>
&lt;th>Deaths&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>44880&lt;/th>
&lt;td>2020-01-22&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44881&lt;/th>
&lt;td>2020-01-23&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44882&lt;/th>
&lt;td>2020-01-24&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44883&lt;/th>
&lt;td>2020-01-25&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44884&lt;/th>
&lt;td>2020-01-26&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;p>let&amp;rsquo;s calculate the infection rate in Italy&lt;/p>
&lt;pre>&lt;code class="language-python">df_italy['Infection Rate']=df_italy.Confirmed.diff()
df_italy.head()
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>/var/folders/43/4nqhk6qx3kxcwf85q5ncg9lm0000gn/T/ipykernel_74583/3001688291.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Country&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;th>Recovered&lt;/th>
&lt;th>Deaths&lt;/th>
&lt;th>Infection Rate&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>44880&lt;/th>
&lt;td>2020-01-22&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>NaN&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44881&lt;/th>
&lt;td>2020-01-23&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44882&lt;/th>
&lt;td>2020-01-24&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44883&lt;/th>
&lt;td>2020-01-25&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44884&lt;/th>
&lt;td>2020-01-26&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;p>ok! now let&amp;rsquo;s do the visualization&lt;/p>
&lt;pre>&lt;code class="language-python">FigIt=px.line(df_italy, x='Date', y='Infection Rate', title=&amp;quot;Before and After lockdown in Italy&amp;quot;)
FigIt.show()
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">FigIt2=px.line(df_italy, x='Date', y='Infection Rate', title=&amp;quot;Before and After lockdown in Italy&amp;quot;)
FigIt2.add_shape(
dict(
type=&amp;quot;line&amp;quot;,
x0=italy_lockdown_start_date,
y0=0,
x1=italy_lockdown_start_date,
y1=df_italy['Infection Rate'].max(),
line=dict(color='red', width=2)
)
)
FigIt2.add_annotation(
dict(
x=italy_lockdown_start_date,
y=df_italy['Infection Rate'].max(),
text='Starting Date of Lockdown'
)
)
FigIt2.show()
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">FigIt3=px.line(df_italy, x='Date', y='Infection Rate', title=&amp;quot;Before and After lockdown in Italy&amp;quot;)
FigIt3.add_shape(
dict(
type=&amp;quot;line&amp;quot;,
x0=italy_lockdown_start_date,
y0=0,
x1=italy_lockdown_start_date,
y1=df_italy['Infection Rate'].max(),
line=dict(color='red', width=2)
)
)
FigIt3.add_annotation(
dict(
x=italy_lockdown_start_date,
y=df_italy['Infection Rate'].max(),
text='Starting Date of Lockdown'
)
)
FigIt3.add_shape(
dict(
type=&amp;quot;line&amp;quot;,
x0=italy_lockdown_a_month_later,
y0=0,
x1=italy_lockdown_a_month_later,
y1=df_italy['Infection Rate'].max(),
line=dict(color='red', width=2)
)
)
FigIt3.add_annotation(
dict(
x=italy_lockdown_a_month_later,
y=4000,
text='One month post Lockdown'
)
)
FigIt3.show()
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>---------------------------------------------------------------------------
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">FigIt2=px.line(df_italy, x='Date', y='Infection Rate', title=&amp;quot;Before and After lockdown in Italy&amp;quot;)
FigIt2.add_shape(
dict(
type=&amp;quot;line&amp;quot;,
x0=italy_lockdown_start_date,
y0=0,
x1=italy_lockdown_start_date,
y1=df_italy['Infection Rate'].max(),
line=dict(color='red', width=2)
)
)
FigIt2.add_annotation(
dict(
x=italy_lockdown_start_date,
y=df_italy['Infection Rate'].max(),
text='Starting Date of Lockdown'
)
)
FigIt2.show()
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>---------------------------------------------------------------------------
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">FigIt3=px.line(df_italy, x='Date', y='Infection Rate', title=&amp;quot;Before and After lockdown in Italy&amp;quot;)
FigIt3.add_shape(
dict(
type=&amp;quot;line&amp;quot;,
x0=italy_lockdown_start_date,
y0=0,
x1=italy_lockdown_start_date,
y1=df_italy['Infection Rate'].max(),
line=dict(color='red', width=2)
)
)
FigIt3.add_annotation(
dict(
x=italy_lockdown_start_date,
y=df_italy['Infection Rate'].max(),
text='Starting Date of Lockdown'
)
)
FigIt3.add_shape(
dict(
type=&amp;quot;line&amp;quot;,
x0=italy_lockdown_a_month_later,
y0=0,
x1=italy_lockdown_a_month_later,
y1=df_italy['Infection Rate'].max(),
line=dict(color='red', width=2)
)
)
FigIt3.add_annotation(
dict(
x=italy_lockdown_a_month_later,
y=4000,
text='One month post Lockdown'
)
)
FigIt3.show()
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>---------------------------------------------------------------------------
&lt;/code>&lt;/pre>
&lt;p>
&lt;figure id="figure-before-and-after-lockdown">
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img alt="Before and After Lockdown" srcset="
/post/covid_analysis_python/data/BeforeAfterLockdown1_huc0916ebbbe0b8a718a9e7205ad5fdd12_66611_884383a832ba8fa0bbe68be2f4c421e5.png 400w,
/post/covid_analysis_python/data/BeforeAfterLockdown1_huc0916ebbbe0b8a718a9e7205ad5fdd12_66611_d6837012f5cc41cb6ea1aaf9fb3b4949.png 760w,
/post/covid_analysis_python/data/BeforeAfterLockdown1_huc0916ebbbe0b8a718a9e7205ad5fdd12_66611_1200x1200_fit_lanczos_2.png 1200w"
src="https://saif-sayeed-resume.netlify.app/post/covid_analysis_python/data/BeforeAfterLockdown1_huc0916ebbbe0b8a718a9e7205ad5fdd12_66611_884383a832ba8fa0bbe68be2f4c421e5.png"
width="760"
height="405"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;figcaption>
Before and After Lockdown
&lt;/figcaption>&lt;/figure>
&lt;/p>
&lt;h3 id="task-5-lets-see-how-national-lockdowns-impacts-covid19-active-cases-in-italy">Task 5: Let&amp;rsquo;s See how National Lockdowns Impacts Covid19 active cases in Italy&lt;/h3>
&lt;pre>&lt;code class="language-python">df_italy.head()
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Country&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;th>Recovered&lt;/th>
&lt;th>Deaths&lt;/th>
&lt;th>Infection Rate&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>44880&lt;/th>
&lt;td>2020-01-22&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>NaN&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44881&lt;/th>
&lt;td>2020-01-23&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44882&lt;/th>
&lt;td>2020-01-24&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44883&lt;/th>
&lt;td>2020-01-25&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44884&lt;/th>
&lt;td>2020-01-26&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;p>let&amp;rsquo;s calculate number of active cases day by day&lt;/p>
&lt;pre>&lt;code class="language-python">df_italy['Death Rate']=df_italy.Deaths.diff()
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>/var/folders/43/4nqhk6qx3kxcwf85q5ncg9lm0000gn/T/ipykernel_74583/834131105.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
&lt;/code>&lt;/pre>
&lt;p>let&amp;rsquo;s check the dataframe again&lt;/p>
&lt;pre>&lt;code class="language-python">df_italy.head()
&lt;/code>&lt;/pre>
&lt;div>
&lt;style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
&lt;pre>&lt;code>.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
&lt;/code>&lt;/pre>
&lt;p>&lt;/style>&lt;/p>
&lt;table border="1" class="dataframe">
&lt;thead>
&lt;tr style="text-align: right;">
&lt;th>&lt;/th>
&lt;th>Date&lt;/th>
&lt;th>Country&lt;/th>
&lt;th>Confirmed&lt;/th>
&lt;th>Recovered&lt;/th>
&lt;th>Deaths&lt;/th>
&lt;th>Infection Rate&lt;/th>
&lt;th>Death Rate&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;th>44880&lt;/th>
&lt;td>2020-01-22&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>NaN&lt;/td>
&lt;td>NaN&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44881&lt;/th>
&lt;td>2020-01-23&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44882&lt;/th>
&lt;td>2020-01-24&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44883&lt;/th>
&lt;td>2020-01-25&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;/tr>
&lt;tr>
&lt;th>44884&lt;/th>
&lt;td>2020-01-26&lt;/td>
&lt;td>Italy&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;td>0.0&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;/div>
&lt;p>now let&amp;rsquo;s plot a line chart to compare COVID19 national lockdowns impacts on spread of the virus and number of active cases&lt;/p>
&lt;pre>&lt;code class="language-python">figit4=px.line(df_italy, x='Date', y=['Infection Rate', 'Death Rate'])
figit4.show()
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>---------------------------------------------------------------------------
&lt;/code>&lt;/pre>
&lt;p>
&lt;figure id="figure-absolute-death-rates-and-infection-rates-before-and-after-lockdown---not-easily-comparable">
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img alt="Absolute Death Rates and Infection Rates Before and After Lockdown - scaling issue" srcset="
/post/covid_analysis_python/data/BeforeAfterLockdown2_hu0c9c85144ea77b97b8540a960c9e987b_54310_d18425f51fc82c4df5db6eed0d6aeef0.png 400w,
/post/covid_analysis_python/data/BeforeAfterLockdown2_hu0c9c85144ea77b97b8540a960c9e987b_54310_10ff90d5ad14894440ae58e4da65a448.png 760w,
/post/covid_analysis_python/data/BeforeAfterLockdown2_hu0c9c85144ea77b97b8540a960c9e987b_54310_1200x1200_fit_lanczos_2.png 1200w"
src="https://saif-sayeed-resume.netlify.app/post/covid_analysis_python/data/BeforeAfterLockdown2_hu0c9c85144ea77b97b8540a960c9e987b_54310_d18425f51fc82c4df5db6eed0d6aeef0.png"
width="760"
height="405"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;figcaption>
Absolute Death Rates and Infection Rates Before and After Lockdown - not easily comparable
&lt;/figcaption>&lt;/figure>
&lt;/p>
&lt;pre>&lt;code class="language-python">df_italy['N Infection Rate']=df_italy['Infection Rate']/df_italy['Infection Rate'].max()
df_italy['N Death Rate']=df_italy['Death Rate']/df_italy['Death Rate'].max()
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>/var/folders/43/4nqhk6qx3kxcwf85q5ncg9lm0000gn/T/ipykernel_74583/3675118474.py:1: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
/var/folders/43/4nqhk6qx3kxcwf85q5ncg9lm0000gn/T/ipykernel_74583/3675118474.py:2: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">figf= px.line(df_italy, x='Date', y=['N Infection Rate', 'N Death Rate'])
figf.show()
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>---------------------------------------------------------------------------
&lt;/code>&lt;/pre>
&lt;pre>&lt;code class="language-python">figf1= px.line(df_italy, x='Date', y=['N Infection Rate', 'N Death Rate'], title=&amp;quot;Infection Rate and Death rate pre and post lockdown&amp;quot;)
figf1.add_shape(
dict(
type=&amp;quot;line&amp;quot;,
x0=italy_lockdown_start_date,
y0=0,
x1=italy_lockdown_start_date,
y1=df_italy['N Infection Rate'].max(),
line=dict(color='yellow', width=2)
)
)
figf1.add_annotation(
dict(
x=italy_lockdown_start_date,
y=df_italy['N Infection Rate'].max(),
text='Starting Date of Lockdown'
)
)
figf1.add_shape(
dict(
type=&amp;quot;line&amp;quot;,
x0=italy_lockdown_a_month_later,
y0=0,
x1=italy_lockdown_a_month_later,
y1=df_italy['N Infection Rate'].max(),
line=dict(color='yellow', width=2)
)
)
figf1.add_annotation(
dict(
x=italy_lockdown_a_month_later,
y=0,
text='One month post Lockdown'
)
)
figf1.show()
&lt;/code>&lt;/pre>
&lt;pre>&lt;code>---------------------------------------------------------------------------
&lt;/code>&lt;/pre>
&lt;p>
&lt;figure id="figure-relative-infection-rates-and-death-rates-before-and-after-lockdown">
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img alt="Relative Infection Rates and Death Rates Before and After Lockdown" srcset="
/post/covid_analysis_python/data/BeforeAfterLockdown3_hu95cd46fcf76c82fe301547e2ac1006a2_74862_334fd8c5d15399a9b2c02c931cc8207e.png 400w,
/post/covid_analysis_python/data/BeforeAfterLockdown3_hu95cd46fcf76c82fe301547e2ac1006a2_74862_f2fc104eed90be03bf1884ff9f8555de.png 760w,
/post/covid_analysis_python/data/BeforeAfterLockdown3_hu95cd46fcf76c82fe301547e2ac1006a2_74862_1200x1200_fit_lanczos_2.png 1200w"
src="https://saif-sayeed-resume.netlify.app/post/covid_analysis_python/data/BeforeAfterLockdown3_hu95cd46fcf76c82fe301547e2ac1006a2_74862_334fd8c5d15399a9b2c02c931cc8207e.png"
width="760"
height="405"
loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;figcaption>
Relative Infection Rates and Death Rates Before and After Lockdown
&lt;/figcaption>&lt;/figure>
&lt;/p>
&lt;pre>&lt;code class="language-python">
&lt;/code>&lt;/pre></description></item><item><title>Relevance of Public Health for Businesses</title><link>https://saif-sayeed-resume.netlify.app/post/relevance-of-public-health-for-businesses/</link><pubDate>Sat, 03 Jul 2021 14:38:17 +0000</pubDate><guid>https://saif-sayeed-resume.netlify.app/post/relevance-of-public-health-for-businesses/</guid><description>&lt;p>As we live in the corona age, a number of observations have emerged very clearly. One of the key observations is the importance of public-private partnership in healthcare research and development. The international vaccination programs were a miracle in the timeliness and scale of delivery through a joint effort of academic institutions and private companies.&lt;/p>
&lt;p>
&lt;figure >
&lt;div class="d-flex justify-content-center">
&lt;div class="w-100" >&lt;img src="https://upload.wikimedia.org/wikipedia/commons/5/50/Pfizer-BioNTech_COVID-19_vaccine_%282020%29_C.jpg" alt="" loading="lazy" data-zoomable />&lt;/div>
&lt;/div>&lt;/figure>
&lt;/p></description></item></channel></rss>