Skip to content
Project: Analyze International Debt Statistics
Humans not only take debts to manage 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.
In this project, you 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. You are going to find the answers to the following questions:
- What is the number of distinct countries present in the database?
- What country has the highest amount of debt?
- What country has the lowest amount of repayments?
Below is a description of the table you will be working with:
international_debt table
international_debt table| Column | Definition | Data Type |
|---|---|---|
| country_name | Name of the country | varchar |
| country_code | Code representing the country | varchar |
| indicator_name | Description of the debt indicator | varchar |
| indicator_code | Code representing the debt indicator | varchar |
| debt | Value of the debt indicator for the given country (in current US dollars) | float |
You will execute SQL queries to answer three questions, as listed in the instructions.
DataFrameas
num_distinct_countries
variable
-- num_distinct_countries
SELECT COUNT(DISTINCT country_name) AS total_distinct_countries
FROM public.international_debt;DataFrameas
highest_debt_country
variable
-- highest_debt_country
SELECT
country_name,
SUM(debt) AS total_debt
FROM public.international_debt
GROUP BY country_name
ORDER BY total_debt DESC
LIMIT 1;DataFrameas
lowest_principal_repayment
variable
-- lowest_principal_repayment
SELECT
country_name,
indicator_name,
SUM(debt) AS lowest_repayment
FROM public.international_debt
WHERE indicator_code = 'DT.AMT.DLXF.CD'
GROUP BY
indicator_name,
country_name
ORDER BY lowest_repayment ASC
LIMIT 1;DataFrameas
df
variable
-- distinct debt indicators
SELECT
DISTINCT(indicator_code) as distinct_debt_indicators
FROM international_debt
GROUP BY distinct_debt_indicators
ORDER BY distinct_debt_indicators;DataFrameas
df1
variable
-- avg debt groupped by indicators
SELECT
indicator_code AS debt_indicator,
ROUND(AVG(debt)/1000000,2) as average_debt,
indicator_name
FROM international_debt
GROUP BY
debt_indicator,
indicator_name
ORDER BY average_debt DESC
LIMIT 10;DataFrameas
df2
variable
-- the most common debt indicators
SELECT
indicator_name,
COUNT(indicator_code) as indicator_count
FROM international_debt
GROUP BY
indicator_code,
indicator_name
ORDER BY indicator_count DESC
LIMIT 20;