├── Analysis_Music_Playlist ├── Report.ipynb ├── chinook.db_.zip └── readme.md ├── Analysis_of_the_2015_World_population ├── Analysis.ipynb ├── factbook.db └── readme.md ├── Analyze International Debt Statistics ├── Analyzing_International_Debt.ipynb ├── datasets │ └── international_debt.zip └── readme.md └── README.md /Analysis_Music_Playlist/Report.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": {}, 6 | "source": [ 7 | "# Music playlist database" 8 | ] 9 | }, 10 | { 11 | "cell_type": "markdown", 12 | "metadata": {}, 13 | "source": [ 14 | "The project relies on the Chinook playlist database provided by Udacity. It answers three simple questions to show my proficiency in SQL for data mining. Here is the ERD of the database in order to understand how tables are joined to one another: " 15 | ] 16 | }, 17 | { 18 | "attachments": {}, 19 | "cell_type": "markdown", 20 | "metadata": {}, 21 | "source": [ 22 | "" 23 | ] 24 | }, 25 | { 26 | "cell_type": "markdown", 27 | "metadata": {}, 28 | "source": [ 29 | "## What are the three most preferred genres?\n" 30 | ] 31 | }, 32 | { 33 | "cell_type": "code", 34 | "execution_count": null, 35 | "metadata": {}, 36 | "outputs": [], 37 | "source": [ 38 | "SELECT\n", 39 | "\n", 40 | " music_type,\n", 41 | "\n", 42 | " SUM(avg_total_sales) AS sum_avg_total_sales_by_genre,\n", 43 | "\n", 44 | " CASE\n", 45 | "\n", 46 | " WHEN SUM(avg_total_sales) >= 20 THEN 'Top'\n", 47 | "\n", 48 | " WHEN SUM(avg_total_sales) > 10 AND\n", 49 | "\n", 50 | " SUM(avg_total_sales) <= 20 THEN 'Medium'\n", 51 | "\n", 52 | " ELSE 'Low'\n", 53 | "\n", 54 | " END AS level_sales\n", 55 | "\n", 56 | "FROM (SELECT DISTINCT\n", 57 | "\n", 58 | " Artist.Name AS artist_name,\n", 59 | "\n", 60 | " Genre.Name AS music_type,\n", 61 | "\n", 62 | " COUNT(Album.AlbumId) AS total_album,\n", 63 | "\n", 64 | " AVG(InvoiceLine.UnitPrice * InvoiceLine.Quantity) AS avg_total_sales\n", 65 | "\n", 66 | "FROM Artist\n", 67 | "\n", 68 | "JOIN Album\n", 69 | "\n", 70 | " ON Artist.ArtistId = Album.ArtistId\n", 71 | "\n", 72 | "JOIN Track\n", 73 | "\n", 74 | " ON Album.AlbumId = Track.AlbumId\n", 75 | "\n", 76 | "JOIN Genre\n", 77 | "\n", 78 | " ON Track.GenreId = Genre.GenreId\n", 79 | "\n", 80 | "JOIN InvoiceLine\n", 81 | "\n", 82 | " ON Track.TrackId = InvoiceLine.TrackId\n", 83 | "\n", 84 | "JOIN Invoice\n", 85 | "\n", 86 | " ON InvoiceLine.InvoiceId = Invoice.InvoiceId\n", 87 | "\n", 88 | "GROUP BY Artist.Name) sub\n", 89 | "\n", 90 | "GROUP BY music_type\n", 91 | "\n", 92 | "ORDER BY sum_avg_total_sales_by_genre DESC;" 93 | ] 94 | }, 95 | { 96 | "attachments": {}, 97 | "cell_type": "markdown", 98 | "metadata": {}, 99 | "source": [ 100 | "" 101 | ] 102 | }, 103 | { 104 | "cell_type": "markdown", 105 | "metadata": {}, 106 | "source": [ 107 | "We looked into the Chinook database to find out what was the volume of sales for each genre and found out what was the most important. It turns out that Rock is by far the most popular music with an average of 47.52 USD in the total of sales. \n", 108 | "\n", 109 | "It is almost 70 percent more than their second most profitable genre: Classical (32,67 USD average). The third most popular genre is Latin with 23,76 USD on average. \n", 110 | "\n", 111 | "It is an important insight in terms of sales and marketing efforts, the company can put more efforts and budget into the most popular genres to boost the sales. " 112 | ] 113 | }, 114 | { 115 | "attachments": {}, 116 | "cell_type": "markdown", 117 | "metadata": {}, 118 | "source": [ 119 | "" 120 | ] 121 | }, 122 | { 123 | "cell_type": "markdown", 124 | "metadata": {}, 125 | "source": [ 126 | "## Which country was the best buyer in 2009?" 127 | ] 128 | }, 129 | { 130 | "cell_type": "code", 131 | "execution_count": null, 132 | "metadata": {}, 133 | "outputs": [], 134 | "source": [ 135 | "SELECT\n", 136 | "\n", 137 | " Customer.Country,\n", 138 | "\n", 139 | " SUM(InvoiceLine.UnitPrice * InvoiceLine.Quantity) AS Total_sales\n", 140 | "\n", 141 | "FROM Artist\n", 142 | "\n", 143 | "JOIN Album\n", 144 | "\n", 145 | " ON Artist.ArtistId = Album.ArtistId\n", 146 | "\n", 147 | "JOIN Track\n", 148 | "\n", 149 | " ON Album.AlbumId = Track.AlbumId\n", 150 | "\n", 151 | "JOIN Genre\n", 152 | "\n", 153 | " ON Track.GenreId = Genre.GenreId\n", 154 | "\n", 155 | "JOIN InvoiceLine\n", 156 | "\n", 157 | " ON Track.TrackId = InvoiceLine.TrackId\n", 158 | "\n", 159 | "JOIN Invoice\n", 160 | "\n", 161 | " ON InvoiceLine.InvoiceId = Invoice.InvoiceId\n", 162 | "\n", 163 | "JOIN Customer\n", 164 | "\n", 165 | " ON Invoice.CustomerId = Customer.CustomerId\n", 166 | "\n", 167 | "WHERE Invoice.InvoiceDate BETWEEN '2009-01-01' AND '2009-12-26'\n", 168 | "\n", 169 | "GROUP BY 1\n", 170 | "\n", 171 | "ORDER BY 2 DESC;" 172 | ] 173 | }, 174 | { 175 | "attachments": {}, 176 | "cell_type": "markdown", 177 | "metadata": {}, 178 | "source": [ 179 | "" 180 | ] 181 | }, 182 | { 183 | "cell_type": "markdown", 184 | "metadata": {}, 185 | "source": [ 186 | "Looking at the total sales in 2009 from our InvoiceLine database, it turns out that the United-States were far ahead in terms of turnover with 104 USD in total. It is 54,8 percent more than their second market, Canada (57 USD). It makes the USA a major market in 2009 in terms of sales. \n", 187 | "\n", 188 | "If the company wished to organize a concert with musics related to the 2000s, we can tell them that the USA, Canada and Germany should be the top 3 regions to put their marketing efforts. " 189 | ] 190 | }, 191 | { 192 | "attachments": {}, 193 | "cell_type": "markdown", 194 | "metadata": {}, 195 | "source": [ 196 | "" 197 | ] 198 | }, 199 | { 200 | "cell_type": "markdown", 201 | "metadata": {}, 202 | "source": [ 203 | "## Which was the most popular album ever sold on the playlist?" 204 | ] 205 | }, 206 | { 207 | "cell_type": "code", 208 | "execution_count": null, 209 | "metadata": {}, 210 | "outputs": [], 211 | "source": [ 212 | "SELECT Genre.Name AS Music_Genre, \n", 213 | "Artist.Name AS Artist_Name, \n", 214 | "Album.Title AS Album_Title, \n", 215 | "SUM (InvoiceLine.InvoiceId) AS Total_Buy\n", 216 | "\n", 217 | "FROM Artist\n", 218 | "\n", 219 | "JOIN Album\n", 220 | "\n", 221 | " ON Artist.ArtistId = Album.ArtistId\n", 222 | "\n", 223 | "JOIN Track\n", 224 | "\n", 225 | " ON Album.AlbumId = Track.AlbumId\n", 226 | "\n", 227 | "JOIN Genre\n", 228 | "\n", 229 | " ON Track.GenreId = Genre.GenreId\n", 230 | "\n", 231 | "JOIN InvoiceLine\n", 232 | "\n", 233 | " ON Track.TrackId = InvoiceLine.TrackId\n", 234 | "\n", 235 | "JOIN Invoice\n", 236 | "\n", 237 | " ON InvoiceLine.InvoiceId = Invoice.InvoiceId\n", 238 | "\n", 239 | "JOIN Customer\n", 240 | "\n", 241 | " ON Invoice.CustomerId = Customer.CustomerId\n", 242 | "\n", 243 | " GROUP BY Music_Genre, Artist_Name, Album_Title\n", 244 | "\n", 245 | " ORDER BY Total_Buy DESC\n", 246 | "\n", 247 | "LIMIT 15;" 248 | ] 249 | }, 250 | { 251 | "attachments": {}, 252 | "cell_type": "markdown", 253 | "metadata": {}, 254 | "source": [ 255 | "" 256 | ] 257 | }, 258 | { 259 | "cell_type": "markdown", 260 | "metadata": {}, 261 | "source": [ 262 | "Looking into the Chinook database, we asked what was the best album ever sold since the beginning. It turns out that the album with the most sales is My Generation - The Very Best Of The Who from the Group The Who, released in 1996. It is a Rock Type music and collaborates or other insights as Rock being the most popular genre in the database.\n", 263 | "\n", 264 | "The turnover generated by My Generation - The Very Best Of The Who was $5,285, it is 83% more than their second best album Acústico MTV (4,409 USD) of Latin genre.\n", 265 | "\n", 266 | "This could be useful from a marketing point of view to promote other albums from the group." 267 | ] 268 | }, 269 | { 270 | "attachments": {}, 271 | "cell_type": "markdown", 272 | "metadata": {}, 273 | "source": [ 274 | "" 275 | ] 276 | }, 277 | { 278 | "cell_type": "markdown", 279 | "metadata": {}, 280 | "source": [ 281 | "## Who was the employee with the most buys and their favorite genre?" 282 | ] 283 | }, 284 | { 285 | "cell_type": "code", 286 | "execution_count": null, 287 | "metadata": {}, 288 | "outputs": [], 289 | "source": [ 290 | "SELECT DISTINCT\n", 291 | "\n", 292 | " Employee.FirstName,\n", 293 | "\n", 294 | " Employee.LastName,\n", 295 | "\n", 296 | " Genre.Name AS Music_Type,\n", 297 | "\n", 298 | " SUM(InvoiceLine.UnitPrice * InvoiceLine.Quantity) AS Total_buy\n", 299 | "\n", 300 | "FROM Artist\n", 301 | "\n", 302 | "JOIN Album\n", 303 | "\n", 304 | " ON Artist.ArtistId = Album.ArtistId\n", 305 | "\n", 306 | "JOIN Track\n", 307 | "\n", 308 | " ON Album.AlbumId = Track.AlbumId\n", 309 | "\n", 310 | "JOIN Genre\n", 311 | "\n", 312 | " ON Track.GenreId = Genre.GenreId\n", 313 | "\n", 314 | "JOIN InvoiceLine\n", 315 | "\n", 316 | " ON Track.TrackId = InvoiceLine.TrackId\n", 317 | "\n", 318 | "JOIN Invoice\n", 319 | "\n", 320 | " ON InvoiceLine.InvoiceId = Invoice.InvoiceId\n", 321 | "\n", 322 | "JOIN Customer\n", 323 | "\n", 324 | " ON Invoice.CustomerId = Customer.CustomerId\n", 325 | "\n", 326 | "JOIN Employee\n", 327 | "\n", 328 | " ON Customer.SupportRepId = EmployeeId\n", 329 | "\n", 330 | "GROUP BY 1,\n", 331 | "\n", 332 | " 2,\n", 333 | "\n", 334 | " 3\n", 335 | "\n", 336 | "ORDER BY 4 DESC;" 337 | ] 338 | }, 339 | { 340 | "attachments": {}, 341 | "cell_type": "markdown", 342 | "metadata": {}, 343 | "source": [ 344 | "" 345 | ] 346 | }, 347 | { 348 | "cell_type": "markdown", 349 | "metadata": {}, 350 | "source": [ 351 | "We asked if employees were also customers. It turns out that out of the 8 employees of the company, 3 (name on the bar charts) from the sales team bought different kind of music genres.\n", 352 | "\n", 353 | "The top three sales were for rock music and Jane Peacock was the employee with the most buys with $ 301 in this music genre.\n", 354 | "\n", 355 | "If the company was to start an internal communication campaign, these employees could be rewarded with some kind of free pass to buy a rock album of their choice for free for instance." 356 | ] 357 | }, 358 | { 359 | "attachments": {}, 360 | "cell_type": "markdown", 361 | "metadata": {}, 362 | "source": [ 363 | "" 364 | ] 365 | }, 366 | { 367 | "cell_type": "code", 368 | "execution_count": null, 369 | "metadata": {}, 370 | "outputs": [], 371 | "source": [] 372 | } 373 | ], 374 | "metadata": { 375 | "kernelspec": { 376 | "display_name": "Python 3", 377 | "language": "python", 378 | "name": "python3" 379 | }, 380 | "language_info": { 381 | "codemirror_mode": { 382 | "name": "ipython", 383 | "version": 3 384 | }, 385 | "file_extension": ".py", 386 | "mimetype": "text/x-python", 387 | "name": "python", 388 | "nbconvert_exporter": "python", 389 | "pygments_lexer": "ipython3", 390 | "version": "3.7.6" 391 | } 392 | }, 393 | "nbformat": 4, 394 | "nbformat_minor": 4 395 | } 396 | -------------------------------------------------------------------------------- /Analysis_Music_Playlist/chinook.db_.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoicChamplong/Data-Analysis-SQL/3386adfe02e4751e8bed9012cfbb63da18d590a5/Analysis_Music_Playlist/chinook.db_.zip -------------------------------------------------------------------------------- /Analysis_Music_Playlist/readme.md: -------------------------------------------------------------------------------- 1 | # Analysis of Chinook playlist 2 | The project relies on the Chinook playlist database provided by Udacity. It answers four simple questions to show my proficiency in SQL for data mining. 3 | -------------------------------------------------------------------------------- /Analysis_of_the_2015_World_population/factbook.db: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LoicChamplong/Data-Analysis-SQL/3386adfe02e4751e8bed9012cfbb63da18d590a5/Analysis_of_the_2015_World_population/factbook.db -------------------------------------------------------------------------------- /Analysis_of_the_2015_World_population/readme.md: -------------------------------------------------------------------------------- 1 | # Analysis of the world population in 2015 2 | 3 |  4 | 5 | In this project, we'll work with data from the [CIA World Factbook](https://www.cia.gov/library/publications/the-world-factbook/), a compendium of statistics about all of the countries on Earth. The Factbook contains demographic information like: 6 | 7 | population - The population as of 2015. population_growth - The annual population growth rate, as a percentage. area - The total land and water area. 8 | 9 | In this project, we'll use SQL in Jupyter Notebook to explore and analyze data from this database. 10 | 11 | ### Database: 12 | 13 | The dataset is quite simple and will not allow us to answer complicated question. It is composed of 11 colums and 262 row. 14 | 15 | - id - id number attribuated to a country. 16 | - code - country code, made from the two first letters of the country. 17 | - area - total area of the country (area_water + area_land). 18 | - population - population of the country 19 | - population_growth - ratio of the population growth in 2015 20 | - birth_rate 21 | - death_rate 22 | - migration_rate - ratio of people that left the country to another. 23 | 24 | It is important to note that the last row (id 262) is not a country but "World" (code: xx). In the end the data is only composed of 261 countries. 25 | 26 | ## Notes: 27 | 28 | The database being very simple, we could answer complicated questions. This project was intented to practise my SQL skills and show knowledge of simple and more complicated queries (subqueries). 29 | -------------------------------------------------------------------------------- /Analyze International Debt Statistics/Analyzing_International_Debt.ipynb: -------------------------------------------------------------------------------- 1 | {"cells":[{"metadata":{"dc":{"key":"4"},"deletable":false,"editable":false,"run_control":{"frozen":true},"tags":["context"]},"cell_type":"markdown","source":"## 1. The World Bank's international debt data\n
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. The World Bank is the organization that provides debt to countries.
\nIn this notebook, we are going to analyze international debt data collected by The World Bank. The dataset contains information about the amount of debt (in USD) owed by developing countries across several categories. We are going to find the answers to questions like:
\nThe first line of code connects us to the international_debt
database where the table international_debt
is residing. Let's first SELECT
all of the columns from the international_debt
table. Also, we'll limit the output to the first ten rows to keep the output clean.
country_name | \ncountry_code | \nindicator_name | \nindicator_code | \ndebt | \n
---|---|---|---|---|
Afghanistan | \nAFG | \nDisbursements on external debt, long-term (DIS, current US$) | \nDT.DIS.DLXF.CD | \n72894453.700000003 | \n
Afghanistan | \nAFG | \nInterest payments on external debt, long-term (INT, current US$) | \nDT.INT.DLXF.CD | \n53239440.100000001 | \n
Afghanistan | \nAFG | \nPPG, bilateral (AMT, current US$) | \nDT.AMT.BLAT.CD | \n61739336.899999999 | \n
Afghanistan | \nAFG | \nPPG, bilateral (DIS, current US$) | \nDT.DIS.BLAT.CD | \n49114729.399999999 | \n
Afghanistan | \nAFG | \nPPG, bilateral (INT, current US$) | \nDT.INT.BLAT.CD | \n39903620.100000001 | \n
Afghanistan | \nAFG | \nPPG, multilateral (AMT, current US$) | \nDT.AMT.MLAT.CD | \n39107845 | \n
Afghanistan | \nAFG | \nPPG, multilateral (DIS, current US$) | \nDT.DIS.MLAT.CD | \n23779724.300000001 | \n
Afghanistan | \nAFG | \nPPG, multilateral (INT, current US$) | \nDT.INT.MLAT.CD | \n13335820 | \n
Afghanistan | \nAFG | \nPPG, official creditors (AMT, current US$) | \nDT.AMT.OFFT.CD | \n100847181.900000006 | \n
Afghanistan | \nAFG | \nPPG, official creditors (DIS, current US$) | \nDT.DIS.OFFT.CD | \n72894453.700000003 | \n
From the first ten rows, we can see the amount of debt owed by Afghanistan 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.
\nWithout 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.
"},{"metadata":{"dc":{"key":"12"},"tags":["sample_code"],"trusted":true},"cell_type":"code","source":"%%sql\nSELECT \n COUNT(DISTINCT country_name) AS total_distinct_countries\nFROM international_debt;","execution_count":271,"outputs":[{"output_type":"stream","text":" * postgresql:///international_debt\n1 rows affected.\n","name":"stdout"},{"output_type":"execute_result","execution_count":271,"data":{"text/plain":"[(124,)]","text/html":"total_distinct_countries | \n
---|
124 | \n
We can see there are a total of 124 countries present on the table. 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.
distinct_debt_indicators | \n
---|
DT.AMT.BLAT.CD | \n
DT.AMT.DLXF.CD | \n
DT.AMT.DPNG.CD | \n
DT.AMT.MLAT.CD | \n
DT.AMT.OFFT.CD | \n
DT.AMT.PBND.CD | \n
DT.AMT.PCBK.CD | \n
DT.AMT.PROP.CD | \n
DT.AMT.PRVT.CD | \n
DT.DIS.BLAT.CD | \n
DT.DIS.DLXF.CD | \n
DT.DIS.MLAT.CD | \n
DT.DIS.OFFT.CD | \n
DT.DIS.PCBK.CD | \n
DT.DIS.PROP.CD | \n
DT.DIS.PRVT.CD | \n
DT.INT.BLAT.CD | \n
DT.INT.DLXF.CD | \n
DT.INT.DPNG.CD | \n
DT.INT.MLAT.CD | \n
DT.INT.OFFT.CD | \n
DT.INT.PBND.CD | \n
DT.INT.PCBK.CD | \n
DT.INT.PROP.CD | \n
DT.INT.PRVT.CD | \n
As mentioned earlier, the financial debt of a particular country represents its economic state. But if we were to project this on an overall global scale, how will we approach it?
\nLet'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.
"},{"metadata":{"dc":{"key":"28"},"tags":["sample_code"],"trusted":true},"cell_type":"code","source":"%%sql\nSELECT \n ROUND(SUM(debt)/1000000, 2) AS total_debt\nFROM international_debt; ","execution_count":275,"outputs":[{"output_type":"stream","text":" * postgresql:///international_debt\n1 rows affected.\n","name":"stdout"},{"output_type":"execute_result","execution_count":275,"data":{"text/plain":"[(Decimal('3079734.49'),)]","text/html":"total_debt | \n
---|
3079734.49 | \n
\"Human beings cannot comprehend very large or very small numbers. It would be useful for us to acknowledge that fact.\" - Daniel Kahneman. That is more than 3 million million USD, an amount which is really hard for us to fathom.
\nNow 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. Note 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.
"},{"metadata":{"dc":{"key":"36"},"tags":["sample_code"],"trusted":true},"cell_type":"code","source":"%%sql\nSELECT \n country_name, \n SUM (debt) AS total_debt\nFROM international_debt\nGROUP BY country_name\nORDER BY total_debt DESC\nLIMIT 1;","execution_count":277,"outputs":[{"output_type":"stream","text":" * postgresql:///international_debt\n1 rows affected.\n","name":"stdout"},{"output_type":"execute_result","execution_count":277,"data":{"text/plain":"[('China', Decimal('285793494734.200001568'))]","text/html":"country_name | \ntotal_debt | \n
---|---|
China | \n285793494734.200001568 | \n
So, it was China. A more in-depth breakdown of China's debts can be found here.
\nWe 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.
"},{"metadata":{"dc":{"key":"44"},"tags":["sample_code"],"trusted":true},"cell_type":"code","source":"%%sql\nSELECT \n indicator_code AS debt_indicator,\n indicator_name,\n AVG (debt) AS average_debt\nFROM international_debt\nGROUP BY 1,2\nORDER BY 3 DESC\nLIMIT 10;","execution_count":279,"outputs":[{"output_type":"stream","text":" * postgresql:///international_debt\n10 rows affected.\n","name":"stdout"},{"output_type":"execute_result","execution_count":279,"data":{"text/plain":"[('DT.AMT.DLXF.CD', 'Principal repayments on external debt, long-term (AMT, current US$)', Decimal('5904868401.499193612')),\n ('DT.AMT.DPNG.CD', 'Principal repayments on external debt, private nonguaranteed (PNG) (AMT, current US$)', Decimal('5161194333.812658349')),\n ('DT.DIS.DLXF.CD', 'Disbursements on external debt, long-term (DIS, current US$)', Decimal('2152041216.890243888')),\n ('DT.DIS.OFFT.CD', 'PPG, official creditors (DIS, current US$)', Decimal('1958983452.859836046')),\n ('DT.AMT.PRVT.CD', 'PPG, private creditors (AMT, current US$)', Decimal('1803694101.963265321')),\n ('DT.INT.DLXF.CD', 'Interest payments on external debt, long-term (INT, current US$)', Decimal('1644024067.650806481')),\n ('DT.DIS.BLAT.CD', 'PPG, bilateral (DIS, current US$)', Decimal('1223139290.398230108')),\n ('DT.INT.DPNG.CD', 'Interest payments on external debt, private nonguaranteed (PNG) (INT, current US$)', Decimal('1220410844.421518983')),\n ('DT.AMT.OFFT.CD', 'PPG, official creditors (AMT, current US$)', Decimal('1191187963.083064523')),\n ('DT.AMT.PBND.CD', 'PPG, bonds (AMT, current US$)', Decimal('1082623947.653623188'))]","text/html":"debt_indicator | \nindicator_name | \naverage_debt | \n
---|---|---|
DT.AMT.DLXF.CD | \nPrincipal repayments on external debt, long-term (AMT, current US$) | \n5904868401.499193612 | \n
DT.AMT.DPNG.CD | \nPrincipal repayments on external debt, private nonguaranteed (PNG) (AMT, current US$) | \n5161194333.812658349 | \n
DT.DIS.DLXF.CD | \nDisbursements on external debt, long-term (DIS, current US$) | \n2152041216.890243888 | \n
DT.DIS.OFFT.CD | \nPPG, official creditors (DIS, current US$) | \n1958983452.859836046 | \n
DT.AMT.PRVT.CD | \nPPG, private creditors (AMT, current US$) | \n1803694101.963265321 | \n
DT.INT.DLXF.CD | \nInterest payments on external debt, long-term (INT, current US$) | \n1644024067.650806481 | \n
DT.DIS.BLAT.CD | \nPPG, bilateral (DIS, current US$) | \n1223139290.398230108 | \n
DT.INT.DPNG.CD | \nInterest payments on external debt, private nonguaranteed (PNG) (INT, current US$) | \n1220410844.421518983 | \n
DT.AMT.OFFT.CD | \nPPG, official creditors (AMT, current US$) | \n1191187963.083064523 | \n
DT.AMT.PBND.CD | \nPPG, bonds (AMT, current US$) | \n1082623947.653623188 | \n
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 here.
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.
\nWe 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's economic condition a bit more specifically.
country_name | \nindicator_name | \n
---|---|
China | \nPrincipal repayments on external debt, long-term (AMT, current US$) | \n
China has the highest amount of debt in the long-term debt (DT.AMT.DLXF.CD
) category. This is verified by The World Bank. It is often a good idea to verify our analyses like this since it validates that our investigations are correct.
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.
"},{"metadata":{"dc":{"key":"60"},"tags":["sample_code"],"trusted":true},"cell_type":"code","source":"%%sql\nSELECT \n indicator_code,\n COUNT (indicator_code) AS indicator_count\nFROM international_debt\nGROUP BY indicator_code\nORDER BY indicator_count DESC, indicator_code DESC\nLIMIT 20;","execution_count":283,"outputs":[{"output_type":"stream","text":" * postgresql:///international_debt\n20 rows affected.\n","name":"stdout"},{"output_type":"execute_result","execution_count":283,"data":{"text/plain":"[('DT.INT.OFFT.CD', 124),\n ('DT.INT.MLAT.CD', 124),\n ('DT.INT.DLXF.CD', 124),\n ('DT.AMT.OFFT.CD', 124),\n ('DT.AMT.MLAT.CD', 124),\n ('DT.AMT.DLXF.CD', 124),\n ('DT.DIS.DLXF.CD', 123),\n ('DT.INT.BLAT.CD', 122),\n ('DT.DIS.OFFT.CD', 122),\n ('DT.AMT.BLAT.CD', 122),\n ('DT.DIS.MLAT.CD', 120),\n ('DT.DIS.BLAT.CD', 113),\n ('DT.INT.PRVT.CD', 98),\n ('DT.AMT.PRVT.CD', 98),\n ('DT.INT.PCBK.CD', 84),\n ('DT.AMT.PCBK.CD', 84),\n ('DT.INT.DPNG.CD', 79),\n ('DT.AMT.DPNG.CD', 79),\n ('DT.INT.PBND.CD', 69),\n ('DT.AMT.PBND.CD', 69)]","text/html":"indicator_code | \nindicator_count | \n
---|---|
DT.INT.OFFT.CD | \n124 | \n
DT.INT.MLAT.CD | \n124 | \n
DT.INT.DLXF.CD | \n124 | \n
DT.AMT.OFFT.CD | \n124 | \n
DT.AMT.MLAT.CD | \n124 | \n
DT.AMT.DLXF.CD | \n124 | \n
DT.DIS.DLXF.CD | \n123 | \n
DT.INT.BLAT.CD | \n122 | \n
DT.DIS.OFFT.CD | \n122 | \n
DT.AMT.BLAT.CD | \n122 | \n
DT.DIS.MLAT.CD | \n120 | \n
DT.DIS.BLAT.CD | \n113 | \n
DT.INT.PRVT.CD | \n98 | \n
DT.AMT.PRVT.CD | \n98 | \n
DT.INT.PCBK.CD | \n84 | \n
DT.AMT.PCBK.CD | \n84 | \n
DT.INT.DPNG.CD | \n79 | \n
DT.AMT.DPNG.CD | \n79 | \n
DT.INT.PBND.CD | \n69 | \n
DT.AMT.PBND.CD | \n69 | \n
There are a total of six debt indicators in which all the countries listed in our dataset have taken debt. The indicator DT.AMT.DLXF.CD
is also there in the list. So, this gives us a clue that all these countries are suffering from a common economic issue. But that is not the end of the story, a part of the story rather.
Let's change tracks from debt_indicator
s now and focus on the amount of debt again. Let'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.
In this notebook, we took a look at debt owed by countries across the globe. We extracted a few summary statistics from the data and unraveled some interesting facts and figures. We also validated our findings to make sure the investigations are correct.
"},{"metadata":{"dc":{"key":"68"},"tags":["sample_code"],"trusted":true},"cell_type":"code","source":"%%sql\nSELECT \n country_name, \n indicator_code, \n MAX (debt) AS maximum_debt\nFROM international_debt\nGROUP BY 1,2\nORDER BY 3 DESC\nLIMIT 10;\n","execution_count":285,"outputs":[{"output_type":"stream","text":" * postgresql:///international_debt\n10 rows affected.\n","name":"stdout"},{"output_type":"execute_result","execution_count":285,"data":{"text/plain":"[('China', 'DT.AMT.DLXF.CD', Decimal('96218620835.699996948')),\n ('Brazil', 'DT.AMT.DLXF.CD', Decimal('90041840304.100006104')),\n ('China', 'DT.AMT.DPNG.CD', Decimal('72392986213.800003052')),\n ('Russian Federation', 'DT.AMT.DLXF.CD', Decimal('66589761833.5')),\n ('Turkey', 'DT.AMT.DLXF.CD', Decimal('51555031005.800003052')),\n ('South Asia', 'DT.AMT.DLXF.CD', Decimal('48756295898.199996948')),\n ('Brazil', 'DT.AMT.PRVT.CD', Decimal('43598697498.599998474')),\n ('Russian Federation', 'DT.AMT.DPNG.CD', Decimal('42800154974.900001526')),\n ('Brazil', 'DT.AMT.DPNG.CD', Decimal('41831444053.300003052')),\n ('Least developed countries: UN classification', 'DT.DIS.DLXF.CD', Decimal('40160766261.599998474'))]","text/html":"country_name | \nindicator_code | \nmaximum_debt | \n
---|---|---|
China | \nDT.AMT.DLXF.CD | \n96218620835.699996948 | \n
Brazil | \nDT.AMT.DLXF.CD | \n90041840304.100006104 | \n
China | \nDT.AMT.DPNG.CD | \n72392986213.800003052 | \n
Russian Federation | \nDT.AMT.DLXF.CD | \n66589761833.5 | \n
Turkey | \nDT.AMT.DLXF.CD | \n51555031005.800003052 | \n
South Asia | \nDT.AMT.DLXF.CD | \n48756295898.199996948 | \n
Brazil | \nDT.AMT.PRVT.CD | \n43598697498.599998474 | \n
Russian Federation | \nDT.AMT.DPNG.CD | \n42800154974.900001526 | \n
Brazil | \nDT.AMT.DPNG.CD | \n41831444053.300003052 | \n
Least developed countries: UN classification | \nDT.DIS.DLXF.CD | \n40160766261.599998474 | \n
K������d�`#d�p�����;����Z]����pKh�����������ɣo���9�1G�/a�I���=� L�,�����ׯ� �����k��Z�����ڣ�|��^����/�^���,�/��{|�����yu�a�]�.���o�ͯ$xw����k��f��]�U� ���D�w������D����O�^?���{���A�~�S�$�H�C�иd.Cq@Z�}-�Al�4%�;�} g�����W����yݼ�?|����]��^~���k���.m��O�^ݾ}{u7�T����~�/>�v�fIX�'�wq��#z��!�K�#6~�=`� )�9�Q�b��9� ��RVb]<8뼻7/��a���%k,��+�30��1��~d�q�K*�=߈��GgY<�۔B�,�)��߯�>*;ѫ����?L���m��U����q�u.�y˗��y �qA�� b�`���,Z��@���:$���ك<���1d���-��3p����)D���OԈLj�7��`��z�ea"�o~��#�O~y�1á��L���>���y�꽒VI\�s�M��H�8͡��;Xr�d��t?�8͉!����#i��J`O+�x}`�f�� �p�`�����d�'�rJg�e�Dg�eFg��ND�&��Vx�3�0��˗iUe%['\g�霽e,���"GKf��[�(�K]i����+ٛ�nߐ�|����+;Ol�d8�hH������9!�,��Q�7�}&����m�m̾�H� 1dc�^��O6�z#1G�wV��Ô:�����s��2�ƨY�А���>��>��m&�b�H�4�$:t�t"~C��_��'�|`/���Q���%�4e�C��F�k �qj?�Tg�=+ZM:�1��o��#>�çs���mбr��rbN��