<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by YATHARTH AGGARWAL on Medium]]></title>
        <description><![CDATA[Stories by YATHARTH AGGARWAL on Medium]]></description>
        <link>https://medium.com/@yatharthagg?source=rss-a1a17d23cb45------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*RtpVX7lu8ztRinA6.</url>
            <title>Stories by YATHARTH AGGARWAL on Medium</title>
            <link>https://medium.com/@yatharthagg?source=rss-a1a17d23cb45------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 13:48:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yatharthagg/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How are Indian states handling the COVID19 outbreak?]]></title>
            <link>https://medium.com/@yatharthagg/how-are-indian-states-handling-the-covid19-outbreak-63b5835d8411?source=rss-a1a17d23cb45------2</link>
            <guid isPermaLink="false">https://medium.com/p/63b5835d8411</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[india]]></category>
            <dc:creator><![CDATA[YATHARTH AGGARWAL]]></dc:creator>
            <pubDate>Sun, 31 May 2020 08:27:09 GMT</pubDate>
            <atom:updated>2020-06-01T10:59:52.179Z</atom:updated>
            <content:encoded><![CDATA[<h4>Python-based visualizations to analyze the spread of novel coronavirus in different States and UTs of India</h4><p>India reported the first confirmed case of the coronavirus infection on 30 January 2020 in the state of Kerala, with a travel history from Wuhan, China. Since then India has confirmed a total of 1,82,143 cases, 86,984 recoveries (including 1 migration), and 5,164 deaths in the country (till 31 May 2020, as per <a href="https://www.mohfw.gov.in/">MoHFW</a>).</p><p>With the onset of the 2nd decade of the 21st century, the world saw one of, if not the biggest disease outbreak. It has proven that still how cripple and hollow human civilization is, we may boast going to space or creating the ‘God particle’. And yet we saw dead bodies piling up, cities deserted, people wearing shield and gears as if some war is going on in every nook and corner of their streets.</p><p>It is time to learn from mistakes, it is time to learn from history and definitely ACT. More info regarding Covid19 can be found with the <a href="https://www.who.int/health-topics/coronavirus#tab=tab_1">WHO link</a>.</p><p>India took the signs of spread pretty seriously initially by announcing a nationwide lockdown on March 24, which happens to be in its 4th version and has been ‘appreciated’ by <a href="https://www.theweek.in/news/india/2020/03/25/coronavirus-united-nations-praises-india-comprehensive-lockdown.html">WHO</a>. In India, health is a state subject and under a federal structure, these state governments have the powers to administer it according to their own will. Although using the <a href="https://en.wikipedia.org/wiki/Disaster_Management_Act,_2005">Disaster Management Act, 2005</a>, and <a href="https://en.wikipedia.org/wiki/Epidemic_Diseases_Act,_1897">Epidemic Diseases Act, 1897</a> the Union government has been making guidelines for the states to follow in order to control the outbreak. FYI, India has 28 States and 8 Union Territories.</p><p>Read more at Wiki: <a href="https://en.wikipedia.org/wiki/COVID-19_pandemic_in_India">https://en.wikipedia.org/wiki/COVID-19_pandemic_in_India</a></p><p>To get a broad <strong><em>India-specific analysi</em></strong>s and see how it performs with the rest of the countries please go through my other article here: <a href="https://medium.com/analytics-vidhya/is-virus-going-viral-plotting-covid19-outbreak-ed0e38543c4f">https://medium.com/analytics-vidhya/is-virus-going-viral-plotting-covid19-outbreak-ed0e38543c4f</a></p><p><strong>Aim: </strong>Here we will see how multiple simple graphs(or subgraphs) in a single plot can provide us with both state-specific analysis and state-wise comparisons of the Covid19 spread. We will deal with multiple components of a disease outbreak and stack them up in real-time. This whole blog can be termed as a data analysis of Covid19 spread in Indian states and Union Territories (UTs). I have used Jupyter notebook for programming various scripts in Python. The GitHub link to the repository is: <a href="https://github.com/yatharthaggarwal/CovidIndia">https://github.com/yatharthaggarwal/CovidIndia</a></p><p><strong>Dataset: </strong>The Government of India updates Covid19 related data on its website: <a href="https://www.mohfw.gov.in/">https://www.mohfw.gov.in/</a>. Whereas the testing data is daily updated on <a href="https://www.icmr.gov.in/">https://www.icmr.gov.in/</a>.</p><p>But the dataset being used here is provided by <a href="https://api.covid19india.org/csv/">https://covid19india.org/</a>, as they provide date-wise data in multiple CSV files. They are channeling the data through crowdsourcing. Any issue or inconsistency with the dataset values can be registered with the above-mentioned portal. Following are the datasets and their corresponding snapshots:</p><ol><li><em>state_wise.csv: </em>Statewise latest update of Confirmed, Recovered and Deceased cases</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Yjr5si-KZZxHrzO3zFalg.png" /></figure><p>2.<em> state_wise_daily.csv</em>: Statewise time-series of Confirmed, Recovered, and Deceased numbers. TT, AN, etc all column names are code for different states and UTs</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/988/1*IoOhcdmKZUeMdcjIe2ykkg.png" /></figure><p>3. <em>statewise_tested_numbers_data.csv</em>: Number of tests conducted by the state, ventilators and hospital bed information reported in state bulletins</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*41t2zP-LBdfYOuw2Nbzn1A.png" /></figure><p>4. Indian states and UT population dataset is downloaded from <a href="http://www.indiaonlinepages.com/population/india-current-population.html">here</a>. Although some changes have been done manually to the dataset, so the new dataset shall be imported directly from the system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*MBYKykwjd0odT4VCJLi5CQ.png" /></figure><p><strong>Python</strong>: I have used the Jupyter Notebook interface for programming the scripts, which in turn runs on the Anaconda platform.</p><p>The graphs are plotted with <strong><em>matplotlib.pyplot</em></strong> package in Python</p><p>There are multiple states plotted in a single graph to study and compare the spread of the pandemic. The code for each script is explained in the CovidIndia Github repository in each of their notebooks.</p><p><strong>General Algorithm</strong>: All scripts follow a general set of steps to get the graph. Those steps are:</p><p>Step 1. Importing required libraries and package</p><p>Step 2. Importing or linking the required datasets</p><p>Step 3. Cleaning the datasets of Nan or any other data which is not required</p><p>Step 4. Formating or creating a new data frame for individual states</p><p>Step 5. Pass a list of states which need to be plotted</p><p>Step 6. Initialize the main plot with dimensions</p><p>Step 7. Loop through these states and create their individual subplots in a larger plot.</p><p>Step 8. Add legends, axis values, fonts, etc, and format the whole plot to make it look good.</p><p><strong>Python Scripts and Visualizations</strong></p><ol><li><a href="https://github.com/yatharthaggarwal/CovidIndia/blob/master/Choropleth_Map_of_ROG_Districts_in_India.ipynb"><strong>Choropleth_Map_of_ROG_Districts_in_India.ipynb</strong></a></li></ol><p>This script plots an interactive choropleth map representing all districts in red, orange, and green colours (These color zones division had been made by the Government of India(GoI)). Also while hovering over districts, details related to Covid19 patients pop up.</p><p>I have made a separate blog for this which covers both the technical aspect and logical interpretation of making it: <a href="https://towardsdatascience.com/coloring-india-red-orange-and-green-covid19-choropleth-map-fc21a00f005f">https://towardsdatascience.com/coloring-india-red-orange-and-green-covid19-choropleth-map-fc21a00f005f</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*Dpu5v4LunQDhJmA7bgiIRg.png" /></figure><p><strong>2. </strong><a href="https://github.com/yatharthaggarwal/CovidIndia/blob/master/States_ADR.ipynb"><strong>States_ADR.ipynb</strong></a></p><p>This script plots stacked bar for multiple states with their Active, Death, and Recovered (ADR) cases over all this time. One could see how each state has tackled this Coronavirus outbreak in terms of their patients’ treatment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PHgC1ruMY7NM3P2qc9zV1g.png" /></figure><p><strong>3. </strong><a href="https://github.com/yatharthaggarwal/CovidIndia/blob/master/States_ConfirmCases_%26_MovingAverage.ipynb"><strong>States_ConfirmCases_&amp;_MovingAverage.ipynb</strong></a></p><p>This script plots a stacked bar for multiple states showing their daily confirmed cases with a 5-day moving average. It also shows total confirmed cases as of the day the graph was plotted. One can analyze the rise and falls of positive cases coming on a daily basis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lyon4bG919pjeVSq5v_N9Q.png" /></figure><p><strong>4. </strong><a href="https://github.com/yatharthaggarwal/CovidIndia/blob/master/States_Positivity_Test_Rate.ipynb"><strong>States_Positivity_Test_Rate.ipynb</strong></a></p><p>This script makes scatter plots for multiple states, showing their tests positivity ratio (in %). It means how many tests turned out positive out of total no. of tests performed in the state. With this one can analyze that the rising positivity means an increase of spread, which in turn suggests more tracing, testing, and isolating is required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TE5wuQ9Dvd27OP473P5XIg.png" /></figure><p><strong>5. </strong><a href="https://github.com/yatharthaggarwal/CovidIndia/blob/master/States_Tests_perMillion.ipynb"><strong>States_Tests_perMillion.ipynb</strong></a></p><p>This script plots horizontal lines graph for multiple states showing their Tests per Million(TPM) data. The graph also shows 3 markers for the last day, last 5th, and last10th day TPM data. One can analyze how much state governments are doing tests per million population (of their state). And also see the rate of growing TPM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2CUnGovo3HRbcBPNFHbU1A.png" /></figure><p><strong>6. </strong><a href="https://github.com/yatharthaggarwal/CovidIndia/blob/master/States_Contribution_inTotal.ipynb"><strong>States_Contribution_inTotal.ipynb</strong></a></p><p>This script plots horizontal lines graph for multiple states and UTs showing their contributions (in %) in total Covid19 cases registered across the nation. The scripts first find out which all states (and UTs) contribute to 1% of total national cases and then plot them. It also shows the total number of confirmed cases against each state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uZLCFm8JtLdzkMJj6nysrg.png" /></figure><p>Feel free to comment, would like to know your thoughts and suggestion.</p><p>Connect with me: <a href="http://noobdatascientist@gmail.com/">noobdatascientist@gmail.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=63b5835d8411" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Coloring India Red, Orange and Green : Covid19 Choropleth Map]]></title>
            <link>https://medium.com/data-science/coloring-india-red-orange-and-green-covid19-choropleth-map-fc21a00f005f?source=rss-a1a17d23cb45------2</link>
            <guid isPermaLink="false">https://medium.com/p/fc21a00f005f</guid>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[choropleth-map]]></category>
            <category><![CDATA[india]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[YATHARTH AGGARWAL]]></dc:creator>
            <pubDate>Thu, 14 May 2020 18:18:31 GMT</pubDate>
            <atom:updated>2020-06-01T11:06:59.385Z</atom:updated>
            <content:encoded><![CDATA[<h3>Coloring India Red, Orange and Green: Covid19 Chloropleth Map</h3><h4>Bokeh-based-plot/map showing different districts in India, with real-time data and outbreak severity of the novel coronavirus</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mUDjPo56_UZ5y2YldOVl3A.jpeg" /><figcaption>Image created from Freepik, see credits in last</figcaption></figure><p><strong><em>Note</em></strong><em>: </em><a href="http://towardsdatascience.com/"><em>Towards Data Science</em></a><em> is a Medium publication primarily based on the study of data science and machine learning. We are not health professionals or epidemiologists, and the opinions of this article should not be interpreted as professional advice. To learn more about the coronavirus pandemic, you can click </em><a href="https://www.who.int/emergencies/diseases/novel-coronavirus-2019/situation-reports"><em>here</em></a><em>.</em></p><p>Covid-19 or novel coronavirus has made the world governments force nation-wide lockdowns, in order to battle against the deadly virus. The virus has now affected more than 4 million people worldwide and left 300k dead.</p><p>India introduced the third lockdown on May 4th for two weeks and is probably planning for lockdown number four. Some believe it is the biggest lockdown anywhere in the world with close to 1.3 billion people confined to their homes. India started colour coding its 733 districts into Red, Orange, and Green Zones depending upon the severity of the disease spread.</p><p><em>Red</em>: a district with the highest caseload contributing to more than 80% cases of each state or a district with a doubling rate of fewer than 4 days.</p><p><em>Green</em>: a district that has not reported any case over 28 days.</p><p><em>Orange</em>: a district which does not fall into either red or green</p><p>The government has tried to use the country’s federal structure to map and isolate the pandemic, create levels of restrictions, allocate resources efficiently, and hold accountability.</p><p>Read more at <a href="https://economictimes.indiatimes.com/news/politics-and-nation/colour-coding-of-districts-in-battle-against-covid-19/articleshow/75416339.cms">Economic Times</a> and <a href="https://www.indiatoday.in/india/story/red-orange-green-zones-full-current-update-list-districts-states-india-coronavirus-1673358-2020-05-01">India Today</a></p><p>As a geek sitting in lockdown, I tried to plot those districts in Python and this blog is about that.</p><p><strong>Aim: </strong>The blog lays out step for creating a choropleth map for districts in India, and mark them with their colours. The map is a type of interactive plot that also shows the number of Covid19 affected people in each district.</p><p>Code has been built in Jupyter Notebook and it can be found on my Github repo: [<a href="https://github.com/yatharthaggarwal/CovidIndia">https://github.com/yatharthaggarwal/CovidIndia</a>]. I have been using the <a href="https://www.anaconda.com/products/individual">Anaconda</a> toolkit for Python-based projects and would recommend the same to others.</p><p><strong>Packages</strong>:</p><ol><li><a href="https://geopandas.org/"><strong>GeoPandas</strong></a><strong>:</strong> is an open-source package that helps users work with geospatial data. The one dependency we will focus on is <em>shapely</em>, on which GeoPandas relies on performing geometric operations. In our case, the shape of each district of India will be encoded as a polygon or multipolygon via the shapely package. Then used through GeoPandas to understand the geospatial data.</li><li><a href="https://docs.bokeh.org/en/latest/"><strong>Bokeh</strong></a><strong>: </strong>it allows us to create more complex plots. Bokeh is a multi-functional, open-source package meant to help users create beautiful and interactive visualizations.</li></ol><p><strong>Importing Datasets</strong></p><p><strong>1. Covid-19 patient data</strong></p><p>First, we need to load the COVID 19 data at the district level. There is NO data made available by GoI/ State governments district wise in India. Therefore we need to rely on crowdsourced-based portals like <a href="https://www.covid19india.org/">https://www.covid19india.org/</a>.</p><p>Even the data provided by them is not correct to a very large percent. They have pushed much of the data in ‘unknown’ sections. But, we are going to take those rows where District is mentioned. The following picture shows the code snippet of loading the dataset, we are interested in Confirmed, Active, Recovered, and Deceased columns. Confirmed cases are a total of the other three.</p><pre>districtdata = pd.read_csv (&#39;<a href="https://api.covid19india.org/csv/latest/district_wise.csv&#39;">https://api.covid19india.org/csv/latest/district_wise.csv&#39;</a>)<br>districtdata.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bEIM2Q7TMjJaDbMEwKauKw.png" /></figure><p><strong>2. India District Shapefile</strong></p><p>In order to create a map, you will need a shapefile (.shp). The file tells Geopandas what shapes we are mapping out. In our case, we need a file that outlines each district. We use a geometry column so that the Geopandas package knows where to look for information for the shapes of each state.</p><p>An excellent updated shapefile can be found here: <a href="https://hub.arcgis.com/datasets/esriindia1::india-districts-boundary">https://hub.arcgis.com/datasets/esriindia1::india-districts-boundary</a>. One can download it from here and use it. Although there are many spelling mistakes, which I have corrected in the data cleaning section. See the code snippet below:</p><pre>df1 = gpd.read_file(&#39;India_Districts/c44c9b96-f570-4ee3-97f1-ebad64efa4c2202044-1-1rb4x6s.8xx6.shp&#39;)<br>df1.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sy-BxYX6r0mlcMOeK8mPFw.png" /></figure><p>We can make use of plot function to see what is in shapefile. If one can find any official file please do comment it. This one does not contain districts made in 2020, but the map comes out beautifully.</p><pre># showing the India map based on the shapefile... See the districts boundary<br>df1.plot(figsize = (8,8))</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*m6rUuGifnuJKDeZe67Mg1w.png" /><figcaption>India districts map from shapefile</figcaption></figure><p><strong>3. District-wise zone data</strong></p><p>The data has been published by the Ministry of Health and Family Welfare. I have directly downloaded it from <a href="https://www.kaggle.com/xordux/india-corona-severity-zones">https://www.kaggle.com/xordux/india-corona-severity-zones</a> and placed it in the working directory. See the code snippet below:</p><pre>zones = pd.read_csv(&#39;Zones in india.csv&#39;)<br>zones.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*09mooi5AdfsbLI6YRyFoew.png" /></figure><p><strong>Data Cleaning</strong></p><p>The data cleaning section is a very necessary part of any data-based project, as it provides means of correcting/removing the data values, working NaN values, and formatting the dataset as a whole. I am not putting the code snippet here as it just corrects a huge number of spelling mistakes. Check the code section in the repository directly which is linked again <a href="https://github.com/yatharthaggarwal/CovidIndia/blob/master/Choropleth_Map_of_ROG_Districts_in_India.ipynb">here</a>.</p><p><strong>Data Pre-Processing</strong></p><p>Creating a common dataframe with all the data shown above.<br>In df1 (shapefile), we merged the Covid19 patients’ data based on District and State, and then the Zones dataframe was similarly merged. A few unnecessary columns were also dropped. In India, often different states keep a similar District name, therefore in the ‘<em>merge’</em> function we need to check both [<em>District’, ‘States’]. </em>See the code snippet which includes geometry, zones, and patient data along with district names and state names:</p><pre>newdf = df1.merge(districtdata[[&#39;State&#39;, &#39;District&#39;, &#39;Confirmed&#39;, &#39;Active&#39;, &#39;Recovered&#39;, &#39;Deceased&#39;]], on = [&#39;District&#39;, &#39;State&#39;])</pre><pre>newdf = newdf.merge(zones[[&#39;State&#39;, &#39;District&#39;, &#39;Zone&#39;]], on = [&#39;District&#39;, &#39;State&#39;])</pre><pre>newdf = newdf.drop(columns = [&#39;statecode&#39;, &#39;state_ut&#39;, &#39;distcode&#39;, &#39;countrynam&#39;])<br>newdf.head()</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iJkOsMlar_2h9ipZ9o3gEg.png" /></figure><p>Now that the data has been converted to the appropriate format, we can plot the choropleth map of districts by following these steps:</p><ol><li>Creating a figure object</li><li>Adding a patch renderer to the figure</li><li>Creating a hover tool which shows the patients data</li><li>Show the figure</li></ol><p><strong>Importing Bokeh library and creating data type format</strong></p><pre>import json<br>from bokeh.io import show<br>from bokeh.io import output_file, save<br>from bokeh.models import (CDSView, ColorBar, ColumnDataSource,<br>                          CustomJS, CustomJSFilter, <br>                          GeoJSONDataSource, HoverTool,<br>                          CategoricalColorMapper, Slider)<br>from bokeh.layouts import column, row, widgetbox<br>from bokeh.io import output_notebook<br>from bokeh.plotting import figure</pre><p>Bokeh consumes GeoJSON format which represents geographical features with JSON. GeoJSON describes points, lines, and polygons (called Patches in Bokeh) as a collection of features. We, therefore, convert the merged file to the GeoJSON format.</p><p>Also, a categorical color mapper is created to map the Red zone with red color and similarly for Green and Orange zones.</p><p>a) Create GeoJSONDataSource object with our initial data</p><pre>geosource = GeoJSONDataSource(geojson = newdf.to_json())</pre><p>b) Define the color palette to use and mapping to categorical values of Zones</p><pre>palette = [&#39;red&#39;, &#39;orange&#39;, &#39;green&#39;]<br>color_mapper = CategoricalColorMapper(palette = palette, factors = [&#39;Red&#39;, &#39;Orange&#39;, &#39;Green&#39;])</pre><p><strong>Choropleth Map</strong></p><p>The following code creates figure object (includes zoom and pan tools), adds a patch rendered (including geosource and mapping color mapper with column zones), and creates a hover tool to display Confirmed, Active, Recovered, and Deceased cases in a particular district.</p><p>And lastly, save the plot in an ‘HTML’ format. Now going through the above-mentioned steps:</p><ol><li>While creating a <em>figure</em> object, we can set title, height, width, and interactive tools for the plot.</li></ol><pre>p = figure(title = &#39;Red, Green and Orange Distric of Covid19: 19 May 2019&#39;,<br>           plot_height = 700 ,<br>           plot_width = 650, <br>           toolbar_location = &#39;right&#39;,<br>           tools = &quot;pan, wheel_zoom, box_zoom, reset&quot;)</pre><p>2. The patch renderer is the main place where we enter data source and color mapper.</p><pre>states = p.patches(&#39;xs&#39;,&#39;ys&#39;, source = geosource,<br>                   fill_color = {&#39;field&#39; :&#39;Zone&#39;,<br>                                 &#39;transform&#39; : color_mapper},<br>                   line_color = &#39;black&#39;,<br>                   line_width = 0.25, <br>                   fill_alpha = 1)</pre><p>3. The Hover tool lets us put the data which we want to show in the plot.</p><pre>p.add_tools(HoverTool(renderers = [states],<br>                      tooltips = [(&#39;District&#39;,&#39;<a href="http://twitter.com/District">@District</a>&#39;),<br>                                  (&#39;State&#39;,&#39;<a href="http://twitter.com/State">@State</a>&#39;),<br>                                  (&#39;Zone&#39;,&#39;<a href="http://twitter.com/Zone">@Zone</a>&#39;),<br>                                  (&#39;Confirmed cases&#39;,&#39;<a href="http://twitter.com/Confirmed">@Confirmed</a>&#39;),<br>                                  (&#39;Active cases&#39;,&#39;<a href="http://twitter.com/Active">@Active</a>&#39;),<br>                                  (&#39;Recovered cases&#39;,&#39;<a href="http://twitter.com/Recovered">@Recovered</a>&#39;),<br>                                  (&#39;Deaths&#39;,&#39;<a href="http://twitter.com/Deceased">@Deceased</a>&#39;)<br>                                 ]))</pre><p>4. Finally the plot in HTML format. It’s a whopping 150 MB. I need to see how can I reduce the size. Save function saves it in the current directory.</p><pre>output_file(&#39;plot.html&#39;, mode=&#39;inline&#39;)<br>save(p)<br>show(p, notebook_handle = True)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ncaYM0pxvoHZd-Kz3go4WA.png" /><figcaption>Choropleth map showing all district zones in India with tools on the right side</figcaption></figure><p>Congrats !! We have successfully created our Choropleth map. One can simply open the plot.html file in any browser to view its content. Or just shoot the following command to see the plot in the new tab.</p><p>I have created a small video showing the interactive map.</p><p><a href="https://www.youtube.com/watch?v=JuF4cNeWKzc">https://www.youtube.com/watch?v=JuF4cNeWKzc</a></p><p>Choropleth map working</p><p>One can see the code <a href="https://github.com/yatharthaggarwal/CovidIndia/blob/master/Choropleth%20Map%20of%20ROG%20Districts%20in%20India%20.ipynb">here</a> directly.</p><p>If you have any comments or suggestions on how we can further enhance the plot or code, I would love to hear them!</p><p>Connect with me: <a href="http://noobdatascientist@gmail.com/">noobdatascientist@gmail.com</a></p><p>Thanks for reading!</p><p><em>The first picture (which also acts as a thumbnail) is created using Freepik’s: </em><a href="https://www.freepik.com/free-vector/india-state-map-outline_558652.htm#page=1&amp;query=india%20map&amp;position=31"><em>India Map</em></a><em>, </em><a href="https://www.freepik.com/free-photo/coronavirus-infection-with-copy-space_7248142.htm#page=1&amp;query=corona&amp;position=25"><em>Corona Infection</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fc21a00f005f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/coloring-india-red-orange-and-green-covid19-choropleth-map-fc21a00f005f">Coloring India Red, Orange and Green : Covid19 Choropleth Map</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is Virus going Viral : Plotting Covid19 outbreak]]></title>
            <link>https://medium.com/analytics-vidhya/is-virus-going-viral-plotting-covid19-outbreak-ed0e38543c4f?source=rss-a1a17d23cb45------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed0e38543c4f</guid>
            <category><![CDATA[covid19]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coronavirus]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[YATHARTH AGGARWAL]]></dc:creator>
            <pubDate>Sun, 10 May 2020 11:05:50 GMT</pubDate>
            <atom:updated>2020-05-31T13:27:30.766Z</atom:updated>
            <content:encoded><![CDATA[<h3>Is Virus going Viral: Plotting Covid19 outbreak</h3><h4>Python-based codes to plot various graphs to understand the spread of novel coronavirus pandemic</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5bH3wdiVEDwo-vnJf26duw.jpeg" /></figure><p><strong><em>Intro to Covid19</em></strong>: It is a newly found coronavirus and happens to spread via coming near to an infectious person, thus becoming highly contagious and life-threatening. It began in Wuhan, China, and now has spread to 180+ countries across the world. One can follow the WHO link <a href="https://www.who.int/emergencies/diseases/novel-coronavirus-2019">here</a>, to know more about it.</p><p><strong><em>Aim of the blog</em></strong>: A disease becomes an outbreak when it spreads across countries and no treatable medication is known. Therefore it becomes essential to track and trace its spread. Governments, International councils, and Institutions related to health\disease\medicine have put in resources to create and maintain datasets related to its spread.</p><p>With really small 6 Python scripts (programs) we can see and analyse single and multiple countries affected by this Coronavirus. One can thereafter quantitatively and qualitatively comment on how a particular country is tackling this situation by seeing different graphs and plots. The scripts can be found here: <a href="https://github.com/yatharthaggarwal/Covid19">https://github.com/yatharthaggarwal/Covid19</a>.</p><p><strong><em>About Myself</em></strong>: I cannot yet consolidate myself to one particular field of Mathematics, Science, Technology, Engineering, or AI, therefore I keep learning new things every day. Academically a Computer Science graduate and professionally doing whatever I like. FYI this is my first Medium blog.</p><p><strong><em>Data Analysis</em></strong>: A process of <em>cleaning</em>, <em>transforming</em>, and <em>modeling</em> data to discover useful information for decision-making. So it makes this blog a data analysis of the Covid19 pandemic and the tools used for doing it are Jupyter Notebooks and datasets from John Hopkins University and World Bank.</p><p><strong><em>Datasets</em></strong>: The dataset being used is a Repository by the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University given on their GitHub page [<a href="https://github.com/CSSEGISandData/COVID-19">https://github.com/CSSEGISandData/COVID-19</a>], the dataset is currently updated every day. They have also created a dashboard [<a href="https://coronavirus.jhu.edu/map.html">https://coronavirus.jhu.edu/map.html</a>] using the same.</p><p>The population data has been taken from the World Bank dataset: <a href="https://data.worldbank.org/indicator/SP.POP.TOTL">https://data.worldbank.org/indicator/SP.POP.TOTL</a>.</p><p>1st Step: Importing and cleaning the datasets :</p><p>The Pandas Library is best suited to do this: We provide raw Github link of CSV files for datasets required. Currently, there are 3 <em>global </em>datasets:</p><p>1: Confirmed Cases: Cumulative new cases that are tested positive daily in each country.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hlNnbC9EBIY0c7OHFsYI-w.png" /></figure><p>2: Death Cases: Cumulative deaths reported daily in each country.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*amD_dUN8QXioUaiP2XOP1w.png" /></figure><p>3: Recovered Cases: Cumulative cases that are tested negative and claimed to have recovered daily in each country.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kF-sd5BXUlSfLjMoUMTnew.png" /></figure><p>In all the 3 datasets, the starting date is 22nd January 2020. And daily the data is updated, so there is nothing much to clean. The indexes are never changed so it becomes pretty easy to parse through the file.</p><p>4. There is also a population data downloaded from World Bank and has been cleaned to fit the requirement. Each country’s value (population) for year = 2018 is taken as latest population data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WnUjwgTlNQ6vKtAynVGK0A.png" /></figure><p><strong>2nd Step: Transforming the dataset</strong></p><p>In this step, we need to transform our dataset in such a manner that we can start using it. It often requires cleaning, removing NaN values, converting categorical data to numerical one, or vice-versa. This step completely depends upon the requirement of the project.</p><p>But this dataset is pretty much cleaned. Though there is still one thing that needs to done i.e. adding up all rows corresponding to a particular country. E.g. there are multiple rows for the country of Canada which we need to combine. The following function does that efficiently, ‘FetchData’ and other Fetch functions do the same thing. They add up all rows column-wise (beginning from the 4th index).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gC9LgVTx0YtaXp4rVq0NOQ.png" /></figure><p><strong>3rd Step: Visualizations</strong></p><p>In an outbreak stricken world, working on live data becomes more phenomenal as it provides how the world is facing / behaving / changing under the pandemic.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/387/0*K302onPgvEIbzeki.png" /></figure><p>Whenever we talk of numbers, mathematical modeling comes hand-in-hand, and there many models, which can analyse a disease outbreak and especially when it is contagious.</p><p>At the beginning of most disease outbreaks, we often see exponential growth. (See equation in the figure).</p><p>There are single country graphs and multiple countries graph to study and compare the spread of the pandemic. The code for each script is explained in the Covid19 Github repository in each of their notebooks. Again I’m linking it here: <a href="https://github.com/yatharthaggarwal/Covid19">https://github.com/yatharthaggarwal/Covid19</a>.</p><p>The following show graphs plotted with <strong><em>matplotlib.pyplot</em></strong> package in Python:</p><p><strong>1. Country_Active_Cases_Analysis_Plot.ipynb [Single country]</strong></p><p>This script plots 2 graphs for a particular country.</p><p>The first graph shows the cumulative Confirmed cases of that country with days, the graph begins when these cases have crossed 300. Also, predictive lines of cases doubling every 3/5/10 days have been plotted.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*Bunw4v_WKNePGPFiuw6LXA.png" /></figure><p>The second graph shows the cumulative Active cases of the same country, it also provides the growth rate of the pandemic for the past 5 days and corresponding doubling days.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*GJfHLTD-nsCZP1r1gS9o9g.png" /></figure><p><strong>2. Country_ ActiveCases_GrowthRate_DoublingDays .ipynb[Single country]</strong></p><p>This script plots daily Growth Rate of Active cases in a red line corresponding to the left y-axis and daily Doubling Days of these Active cases in a green line corresponding to the right y-axis.</p><pre>P1 = P0 x e ^ (Rt)<br>to calculate growth rate(R), we take P1, P0 as active cases at a difference of 5 days and t = 5 days</pre><pre>ln(2)/R = t<br>to calculate doubling days based on above calculated R.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-ybIldf3uBZPn6gLXB3C4A.png" /></figure><p><strong>2. Country_Confirmed_Cases_Moving_Average_Plot.ipynb [Single country]</strong></p><p>This script plots a 7-day moving average of confirmed cases (daily Coronavirus positive cases) for a particular country. It also shows daily confirmed cases as deviations from the moving average.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*e-L7_o4cvSIXuVKRyR4Deg.png" /></figure><p><strong>3. World_Active_Death_Recovered_Cases_Plot.ipynb [Multiple countries]</strong></p><p>This script plots stacked bar for multiple countries with their Active, Death, and Recovered (ADR) cases over all this time. One could see how each country has tackled this Coronavirus outbreak and which countries have flattened the curve.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0pU4PFSSdwJjyo8eQ8t5Qg.png" /></figure><p><strong>4. World_Confirmed_Cases_Plot.ipynb [Multiple countries]</strong></p><p>This script plots Country-wise cumulative confirmed cases data over several days in a single graph. The data takes in days since the countries got their first 100 cases. One can focus on how each country fared in the pandemic since.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BZlbhJ50hUGmFRj6OhkLtA.png" /></figure><p><strong>5. World_Deaths_ per_Million_Plot.ipynb [Multiple countries]</strong></p><p>This script plots horizontal lines graph for multiple countries showing their Death per Million(DPM) data. The graph also shows 3 markers for the last day and last 5th, 10th day DPM data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j176RO67VFhzomPDGP2-Hw.png" /></figure><p><strong>6. World_Fatality_Rate_Plot.ipynb [Multiple countries]</strong></p><p>This script plots Case Fatality Rate (CFR) for multiple countries over these number of days. One could analyze the probability of someone dying from Coronavirus across time.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CRsZGVyGybXT8i1GmJ8mjg.png" /></figure><p>Blog Thumbnail: Business photo created by master1305 — <a href="http://www.freepik.com/">www.freepik.com</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed0e38543c4f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/is-virus-going-viral-plotting-covid19-outbreak-ed0e38543c4f">Is Virus going Viral : Plotting Covid19 outbreak</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>