<?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 Manav on Medium]]></title>
        <description><![CDATA[Stories by Manav on Medium]]></description>
        <link>https://medium.com/@manav.m?source=rss-ec663df48b28------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*g-ye05ls4AS4kby3.jpg</url>
            <title>Stories by Manav on Medium</title>
            <link>https://medium.com/@manav.m?source=rss-ec663df48b28------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 00:08:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@manav.m/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[Exploring 67 Years of LEGO]]></title>
            <link>https://medium.com/@manav.m/exploring-67-years-of-lego-16b55040d7b3?source=rss-ec663df48b28------2</link>
            <guid isPermaLink="false">https://medium.com/p/16b55040d7b3</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[lego]]></category>
            <dc:creator><![CDATA[Manav]]></dc:creator>
            <pubDate>Wed, 01 Apr 2020 11:19:52 GMT</pubDate>
            <atom:updated>2020-04-01T11:19:52.025Z</atom:updated>
            <content:encoded><![CDATA[<h3>1. Introduction</h3><p>Everyone loves Lego (unless you ever stepped on one). Did you know by the way that “Lego” was derived from the Danish phrase leg godt, which means “play well”? Unless you speak Danish, probably not.</p><p>In this project, we will analyze a fascinating dataset on every single lego block that has ever been built!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*13pOHMokpp8HaMsj.jpeg" /></figure><h3>2. Reading Data</h3><p>A comprehensive database of lego blocks is provided by <a href="https://rebrickable.com/downloads/">Rebrickable</a>. The data is available as csv files and the schema is shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/629/0*ky14iyNpLsaBDck-.png" /></figure><p>Let us start by reading in the colors data to get a sense of the diversity of lego sets!</p><p>In [149]:</p><pre><em># Import modules</em></pre><pre><strong>import</strong> pandas <strong>as</strong> pd</pre><pre>​</pre><pre><em># Read colors data</em></pre><pre>colors = pd.read_csv(&#39;datasets/colors.csv&#39;)</pre><pre>​</pre><pre><em># Print the first few rows</em></pre><pre>colors.head()</pre><p>Out[149]:</p><p>idnamergbis_trans0–1Unknown0033B2f10Black05131Df21Blue0055BFf32Green237841f43Dark Turquoise008F9Bf</p><h3>3. Exploring Colors</h3><p>Now that we have read the colors data, we can start exploring it! Let us start by understanding the number of colors available.</p><p>In [151]:</p><pre><em># How many distinct colors are available?</em></pre><pre>colors.shape</pre><pre>num_colors = colors[&#39;name&#39;].count()</pre><pre>print(num_colors)</pre><pre>135</pre><h3>4. Transparent Colors in Lego Sets</h3><p>The colors data has a column named is_trans that indicates whether a color is transparent or not. It would be interesting to explore the distribution of transparent vs. non-transparent colors.</p><p>In [153]:</p><pre><em># colors_summary: Distribution of colors based on transparency</em></pre><pre>colors_summary = colors.groupby(&#39;is_trans&#39;).count()</pre><pre>print(colors_summary)</pre><pre>id  name  rgb<br>is_trans                <br>f         107   107  107<br>t          28    28   28</pre><h3>5. Explore Lego Sets</h3><p>Another interesting dataset available in this database is the sets data. It contains a comprehensive list of sets over the years and the number of parts that each of these sets contained.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/0*T0zrIcSy243CJqK8.png" /></figure><p>Let us use this data to explore how the average number of parts in Lego sets has varied over the years.</p><p>In [155]:</p><pre><strong>import</strong> matplotlib <strong>as</strong> plt</pre><pre><strong>%</strong>matplotlib inline</pre><pre><em># Read sets data as `sets`</em></pre><pre>sets = pd.read_csv(&#39;datasets/sets.csv&#39;)</pre><pre><em># Create a summary of average number of parts by year: `parts_by_year`</em></pre><pre>parts_by_year = (sets.groupby(&#39;year&#39;).sum()<strong>/</strong>sets.groupby(&#39;year&#39;).count()).loc[:,[&#39;num_parts&#39;]]</pre><pre>​</pre><pre><em># Plot trends in average number of parts by year</em></pre><pre>print(parts_by_year)</pre><pre>num_parts<br>year            <br>1950   10.142857<br>1953   16.500000<br>1954   12.357143<br>1955   36.857143<br>1956   18.500000<br>1957   42.619048<br>1958   44.452381<br>1959   16.250000<br>1960  175.333333<br>1961   70.588235<br>1962   81.750000<br>1963   33.333333<br>1964   82.636364<br>1965  107.100000<br>1966   40.651685<br>1967   98.666667<br>1968  127.200000<br>1969   64.594203<br>1970   84.793103<br>1971   67.022222<br>1972  102.842105<br>1973  103.367647<br>1974  116.769231<br>1975  155.225806<br>1976  153.029412<br>1977   91.500000<br>1978  146.616438<br>1979  105.414634<br>1980  126.636364<br>1981   97.835443<br>...          ...<br>1988  144.250000<br>1989  102.061404<br>1990  202.035294<br>1991  166.424528<br>1992  119.617391<br>1993  148.432432<br>1994  127.640625<br>1995  179.039062<br>1996  201.770833<br>1997  129.221649<br>1998  141.126154<br>1999  105.543333<br>2000  104.376147<br>2001  104.365782<br>2002  115.700224<br>2003  159.681928<br>2004  138.862534<br>2005  198.745455<br>2006  246.904594<br>2007  229.025078<br>2008  231.644699<br>2009  196.898263<br>2010  210.646396<br>2011  160.452191<br>2012  149.808130<br>2013  181.359191<br>2014  169.320280<br>2015  200.223881<br>2016  248.945813<br>2017  300.121277</pre><pre>[66 rows x 1 columns]</pre><h3>6. Lego Themes Over Years</h3><p>Lego blocks ship under multiple <a href="https://shop.lego.com/en-US/Themes">themes</a>. Let us try to get a sense of how the number of themes shipped has varied over the years.</p><p>In [157]:</p><pre><em># themes_by_year: Number of themes shipped by year</em></pre><pre>themes_by_year = sets.groupby([&#39;year&#39;], as_index=<strong>False</strong>).count().loc[:,[&#39;year&#39;, &#39;theme_id&#39;]]</pre><pre>print(themes_by_year.head(2))</pre><pre>year  theme_id<br>0  1950         7<br>1  1953         4</pre><h3>7. Wrapping It All Up!</h3><p>Lego blocks offer an unlimited amount of fun across ages. We explored some interesting trends around colors, parts, and themes.</p><p>#Python #Data Analysis #LEGO#EDA#Jupyter Notebook</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16b55040d7b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL-ANALYZING INTERNATIONAL DEBT STATISTICS (DataCamp Project)]]></title>
            <link>https://medium.com/@manav.m/sql-analyzing-international-debt-statistics-datacamp-project-540c0b36f5e6?source=rss-ec663df48b28------2</link>
            <guid isPermaLink="false">https://medium.com/p/540c0b36f5e6</guid>
            <category><![CDATA[world-bank]]></category>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[debt]]></category>
            <category><![CDATA[jupyter-notebook]]></category>
            <category><![CDATA[data-analytics]]></category>
            <dc:creator><![CDATA[Manav]]></dc:creator>
            <pubDate>Mon, 27 Jan 2020 11:47:09 GMT</pubDate>
            <atom:updated>2020-01-27T12:20:35.625Z</atom:updated>
            <content:encoded><![CDATA[<h3>SQL-ANALYZING INTERNATIONAL DEBT STATISTICS</h3><h3>1. The World Bank’s international debt data</h3><p>It’s not that we humans only take debts to manage our necessities. A country may also take debt to manage its economy. For example, infrastructure spending is one costly ingredient required for a country’s citizens to lead comfortable lives. <a href="https://www.worldbank.org/">The World Bank</a> is the organization that provides debt to countries.</p><p>In this notebook, we are going to analyze international debt data collected by The World Bank. The data set contains information about the amount of debt (in USD) owed by developing countries across several categories. This project is going to use partial data set to explore the debt statistics of developing countries and further analyze their economic conditions and their major loan purpose. This project is entirely conducted in Jupyter Notebook using SQL.</p><p>We are going to find the answers to questions like:</p><ul><li>What is the total amount of debt that is owed by the countries listed in the dataset?</li><li>Which country owns the maximum amount of debt and what does that amount look like?</li><li>What is the average amount of debt owed by countries across different debt indicators?</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*pDIln02Hs0Rvi0e2.jpg" /></figure><p>The first line of code connects us to the international_debt database where the table international_debt is residing. Let&#39;s first SELECT <em>all</em> of the columns from the international_debt table. Also, we&#39;ll limit the output to the first ten rows to keep the output clean.</p><pre><strong>%%</strong>sql</pre><pre>postgresql:<strong>///</strong>international_debt</pre><pre>Select <strong>*</strong> <strong>from</strong> international_debt limit 10;</pre><pre>10 rows affected.</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*6UdQrWvaYg3X4C7N.png" /></figure><h3>2. Finding the number of distinct countries</h3><p>From the first ten rows, we can see the amount of debt owed by <em>Afghanistan</em> in the different debt indicators. But we do not know the number of different countries we have on the table. There are repetitions in the country names because a country is most likely to have debt in more than one debt indicator.</p><p>Without a count of unique countries, we will not be able to perform our statistical analyses holistically. In this section, we are going to extract the number of unique countries present in the table.</p><p>In [4]:</p><pre><strong>%%</strong>sql<br>SELECT<br>Count(DISTINCT country_name) AS total_distinct_countries<br>FROM international_debt;</pre><p>There are 124 distinct countries.</p><p>total_distinct_countries</p><p>124</p><h3>3. Finding out the distinct debt indicators</h3><p>As we saw in the first section, there is a column called indicator_name that briefly specifies the purpose of taking the debt. Just beside that column, there is another column called indicator_code which symbolizes the category of these debts. Knowing about these various debt indicators will help us to understand the areas in which a country can possibly be indebted to.</p><p>%%sql<br>SELECT DISTINCT indicator_code AS distinct_debt_indicators<br>FROM international_debt<br>ORDER BY distinct_debt_indicators;</p><p>There are 25 rows in total, including</p><p>1)DT.AMT.BLAT.CD, 2)DT.AMT.DLXF.CD, 3)DT.AMT.DPNG.CD, 4)DT.AMT.MLAT.CD 5)DT.AMT.OFFT.CD, 6)DT.AMT.PBND.CD, 7)DT.AMT.PCBK.CD 8)DT.AMT.PROP.CD, 9)DT.AMT.PRVT.CD, 10)DT.DIS.BLAT.CD 11)DT.DIS.DLXF.CD, 12)DT.DIS.MLAT.CD, 13)DT.DIS.OFFT.CD, 14)DT.DIS.PCBK.CD, 15)DT.DIS.PROP.CD, 16)DT.DIS.PRVT.CD 17)DT.INT.BLAT.CD, 18)DT.INT.DLXF.CD, 19)DT.INT.DPNG.CD, 20)DT.INT.MLAT.CD, 21)DT.INT.OFFT.CD, 22)DT.INT.PBND.CD, 23)DT.INT.PCBK.CD, 24)DT.INT.PROP.CD, 25)DT.INT.PRVT.CD.</p><h3>4. Totaling the amount of debt owed by the countries</h3><p><strong>Aggregate Analysis — Total debt</strong></p><p>Let’s switch gears from the debt indicators now and find out the total amount of debt (in USD) that is owed by the different countries. This will give us a sense of how the overall economy of the entire world is holding up.</p><p>After a glance at the dataset, we are going to approach the analysis from a bigger picture — what is the amount of the total debt in the entire world.</p><pre>%%sql<br>SELECT ROUND(SUM(debt)/1000000, 2) AS total_debt <em>#presented unit in million and rounded to 2 decimals<br></em> <br>FROM international_debt;</pre><p>total_debt 3079734.49</p><p>We can conclude that the world Total debt is $ 3,079,734.49 million.</p><h3>5. Country with the highest debt</h3><p><strong>Aggregate Analysis — The highest debt</strong></p><p>Now that we have the exact total of the amounts of debt owed by several countries, let’s now find out the country that owns the highest amount of debt along with the amount. <strong>Note</strong> that this debt is the sum of different debts owed by a country across several categories. This will help to understand more about the country in terms of its socio-economic scenarios. We can also find out the category in which the country owns its highest debt. But we will leave that for now.</p><pre>%%sql<br>SELECT country_name, SUM(debt) AS total_debt<br>FROM international_debt<br>GROUP BY country_name<br>ORDER BY total_debt DESC<br>LIMIT 1;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*FDPXvcPa1QtCLzMw.png" /></figure><h3>6. Average amount of debt across indicators</h3><p>So, it was <em>China</em>. A more in-depth breakdown of China’s debts can be found <a href="https://datatopics.worldbank.org/debt/ids/country/CHN">here</a>.</p><p>We now have a brief overview of the dataset and a few of its summary statistics. We already have an idea of the different debt indicators in which the countries owe their debts. We can dig even further to find out on an average how much debt a country owes? This will give us a better sense of the distribution of the amount of debt across different indicators.</p><p>Aggregate Analysis — average debt across indicators</p><pre>%%sql<br>SELECT <br> indicator_code AS debt_indicator,<br> indicator_name,<br> AVG(debt) AS average_debt<br>FROM international_debt<br>GROUP BY debt_indicator, indicator_name<br>ORDER BY average_debt DESC<br>LIMIT 10;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*8Bx_mazybSpF1E33.png" /></figure><h3>7. The highest amount of principal repayments</h3><p>We can see that the indicator DT.AMT.DLXF.CD tops the chart of average debt. This category includes repayment of long term debts. Countries take on long-term debt to acquire immediate capital. More information about this category can be found <a href="https://datacatalog.worldbank.org/principal-repayments-external-debt-long-term-amt-current-us-0">here</a>.</p><p>An interesting observation in the above finding is that there is a huge difference in the amounts of the indicators after the second one. This indicates that the first two indicators might be the most severe categories in which the countries owe their debts.</p><p>We can investigate this a bit more so as to find out which country owes the highest amount of debt in the category of long term debts (DT.AMT.DLXF.CD). Since not all the countries suffer from the same kind of economic disturbances, this finding will allow us to understand that particular country&#39;s economic condition a bit more specifically.</p><p><strong>Aggregate Analysis — Which country owe the most in long-term debt</strong></p><pre>%%sql<br>SELECT country_name, indicator_name<br>FROM international_debt<br>WHERE debt= (SELECT MAX(debt)<br> FROM international_debt<br> WHERE indicator_code =’DT.AMT.DLXF.CD’<br> GROUP BY country_name, indicator_code <br> ORDER BY MAX(debt) DESC<br> LIMIT 1<br>);</pre><p>China owes the most in terms of long-term debt loaned by WorldBank.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*Hd-37ZZKUdnAkjVY.png" /></figure><h3>8. The most common debt indicator</h3><p><strong>Aggregate Analysis — Distinct count of indicators</strong></p><p>We saw that long-term debt is the topmost category when it comes to the average amount of debt. But is it the most common indicator in which the countries owe their debt? Let’s find that out.</p><pre>%%sql<br>SELECT indicator_code, COUNT(indicator_code) AS indicator_count<br>FROM international_debt<br>GROUP BY indicator_code<br>ORDER BY indicator_count DESC, indicator_code DESC</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*VLy2v1pSm2lEXjla.png" /></figure><h3>9. Other viable debt issues and conclusion</h3><p><strong>Aggregate Analysis — The countries owe the most across cateogries</strong></p><p>Let’s change tracks from debt_indicators now and focus on the amount of debt again. Let&#39;s find out the maximum amount of debt across the indicators along with the respective country names. With this, we will be in a position to identify the other plausible economic issues a country might be going through. By the end of this section, we will have found out the debt indicators in which a country owes its highest debt.</p><pre>%%sql<br>SELECT country_name, indicator_code, MAX(debt) as maximum_debt<br>FROM international_debt<br>GROUP by country_name, indicator_code<br>ORDER BY maximum_debt DESC<br>LIMIT 10;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*yqzOo42turcxr1L4.png" /></figure><p>In this project, we use SQL to explore the IDS dataset in Jupyter Notebook. Debt Statistics give us a brief idea what problems each countries might work on, which can be further broken down into detail for research.</p><p>Reference: DataCamp</p><p><a href="https://www.datacamp.com/projects/754">Analyze International Debt Statistics - SQL - Online Project</a></p><p>#SQL #Data Analysis #World Bank #Debt Analysis #Jupyter Notebook</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=540c0b36f5e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>