Internally displaced persons, new displacement associated with disasters (number of cases)

Source: worldbank.org, 19.12.2024

Year: 2023

Flag Country Value Value change, % Rank
Afghanistan Afghanistan 418,000 +90% 15
Angola Angola 79,000 +4,289% 34
Albania Albania 13 -95.9% 121
Argentina Argentina 9,800 +1,242% 59
Antigua & Barbuda Antigua & Barbuda 300 -78.6% 98
Australia Australia 4,700 -72.4% 68
Austria Austria 670 +900% 89
Azerbaijan Azerbaijan 1,700 +795% 80
Burundi Burundi 21,000 +61.5% 52
Belgium Belgium 100 0% 104
Burkina Faso Burkina Faso 24,000 +900% 50
Bangladesh Bangladesh 1,791,000 +17.5% 5
Bulgaria Bulgaria 250 -72.2% 100
Bosnia & Herzegovina Bosnia & Herzegovina 120 +53.8% 103
Belarus Belarus 48 113
Bolivia Bolivia 3,800 +26.7% 73
Brazil Brazil 745,000 +5.23% 7
Barbados Barbados 29 -92.4% 117
Botswana Botswana 99 -87.3% 105
Central African Republic Central African Republic 70,000 -9.09% 35
Canada Canada 192,000 +1,180% 22
Switzerland Switzerland 410 +521% 95
Chile Chile 44,000 +2,833% 44
China China 4,702,000 +29.5% 1
Côte d’Ivoire Côte d’Ivoire 1,200 -52% 83
Cameroon Cameroon 2,900 -95.6% 76
Congo - Kinshasa Congo - Kinshasa 133,000 -68.6% 28
Congo - Brazzaville Congo - Brazzaville 159,000 +279% 26
Colombia Colombia 351,000 +24.9% 16
Costa Rica Costa Rica 290 -81.9% 99
Cuba Cuba 42,000 -53.3% 45
Cyprus Cyprus 57 +5.56% 110
Czechia Czechia 64 -97.7% 109
Germany Germany 3,300 +424% 74
Denmark Denmark 520 +2,500% 94
Dominican Republic Dominican Republic 41,000 -24.1% 46
Algeria Algeria 23,000 +1,050% 51
Ecuador Ecuador 16,000 +150% 55
Egypt Egypt 8 -99.3% 122
Spain Spain 24,000 -22.6% 50
Ethiopia Ethiopia 618,000 -29.2% 13
Finland Finland 2 -75% 124
Fiji Fiji 6,700 +39.6% 64
France France 7,900 -82.4% 63
Micronesia (Federated States of) Micronesia (Federated States of) 5 -99.9% 123
Gabon Gabon 900 +44,900% 85
United Kingdom United Kingdom 4,600 +142% 69
Georgia Georgia 850 +97.7% 86
Ghana Ghana 47,000 +1,641% 42
Guinea Guinea 35,000 +10,194% 49
Gambia Gambia 5,300 -24.3% 66
Greece Greece 91,000 +12,717% 33
Guatemala Guatemala 48,000 -35.1% 41
Guam Guam 1,600 +256% 81
Guyana Guyana 40 -66.7% 115
Hong Kong SAR China Hong Kong SAR China 1,300 +294% 82
Honduras Honduras 5,800 -87.4% 65
Croatia Croatia 86 -14% 106
Haiti Haiti 9,800 -34.7% 59
Hungary Hungary 66 +371% 108
Indonesia Indonesia 238,000 -22.7% 18
Isle of Man Isle of Man 5 123
India India 528,000 -78.9% 14
Ireland Ireland 17 -34.6% 119
Iran Iran 124,000 +195% 29
Iraq Iraq 36,000 -29.4% 48
Iceland Iceland 4,600 +8,114% 69
Israel Israel 42 -98.9% 114
Italy Italy 42,000 +924% 45
Jordan Jordan 340 +143% 97
Japan Japan 8,600 -83.1% 61
Kazakhstan Kazakhstan 1,700 -57.5% 80
Kenya Kenya 641,000 +102% 12
Kyrgyzstan Kyrgyzstan 39 -97.7% 116
Cambodia Cambodia 46,000 +64.3% 43
South Korea South Korea 40,000 +33.3% 47
Laos Laos 1,100 +96.4% 84
Lebanon Lebanon 170 +386% 101
Liberia Liberia 14,000 +278% 57
Libya Libya 53,000 +4,317% 39
Sri Lanka Sri Lanka 17,000 +54.5% 54
Macao SAR China Macao SAR China 3,100 +8,278% 75
Morocco Morocco 146,000 +1,437% 27
Madagascar Madagascar 117,000 -59.8% 30
Maldives Maldives 54 -85.4% 111
Mexico Mexico 196,000 +1,682% 21
Mali Mali 1,300 -94.6% 82
Myanmar (Burma) Myanmar (Burma) 995,000 +7,554% 6
Montenegro Montenegro 1 -83.3% 125
Mongolia Mongolia 3,900 +5,100% 72
Northern Mariana Islands Northern Mariana Islands 1,100 +26.4% 84
Mozambique Mozambique 655,000 +480% 11
Mauritania Mauritania 1,100 -95.2% 84
Mauritius Mauritius 2,300 +1,543% 79
Malawi Malawi 660,000 +122% 10
Malaysia Malaysia 206,000 +32.1% 19
Namibia Namibia 650 +150% 91
New Caledonia New Caledonia 2 -98.8% 124
Niger Niger 95,000 -61.7% 32
Nigeria Nigeria 166,000 -93.2% 25
Nicaragua Nicaragua 660 -95.9% 90
Norway Norway 5,800 +3,312% 65
Nepal Nepal 110,000 +18.3% 31
New Zealand New Zealand 14,000 +400% 57
Oman Oman 4,500 +9,900% 70
Pakistan Pakistan 732,000 -91% 8
Panama Panama 26 -94.3% 118
Peru Peru 188,000 +683% 23
Philippines Philippines 2,594,000 -52.4% 3
Papua New Guinea Papua New Guinea 13,000 +35.4% 58
Portugal Portugal 1,700 -62.2% 80
Paraguay Paraguay 16,000 +319,900% 55
Romania Romania 51 -68.1% 112
Russia Russia 15,000 +456% 56
Rwanda Rwanda 70,000 +797% 35
Sudan Sudan 58,000 -44.8% 38
Solomon Islands Solomon Islands 640 +5,718% 92
El Salvador El Salvador 5,300 +15.2% 66
Somalia Somalia 2,043,000 +77.3% 4
Serbia Serbia 400 +39,900% 96
South Sudan South Sudan 167,000 -72% 24
Slovakia Slovakia 86 +43.3% 106
Slovenia Slovenia 8,200 +1,540% 62
Syria Syria 702,000 +3,243% 9
Chad Chad 16,000 -89.9% 55
Thailand Thailand 2,800 -87.3% 77
Tajikistan Tajikistan 5,100 +1,862% 67
Tunisia Tunisia 2,600 +30% 78
Turkey Turkey 4,053,000 +58,639% 2
Tanzania Tanzania 46,000 +995% 43
Uganda Uganda 50,000 +47.1% 40
Ukraine Ukraine 600 +59,900% 93
Uruguay Uruguay 4,300 +438% 71
United States United States 202,000 -70.1% 20
St. Vincent & Grenadines St. Vincent & Grenadines 150 +4,900% 102
Venezuela Venezuela 730 -94.4% 87
Vietnam Vietnam 68,000 -80.7% 37
Vanuatu Vanuatu 69,000 +17,592% 36
Samoa Samoa 14 0% 120
Kosovo Kosovo 1,100 +817% 84
Yemen Yemen 240,000 +40.4% 17
South Africa South Africa 20,000 -67.7% 53
Zambia Zambia 9,300 +158% 60
Zimbabwe Zimbabwe 690 -46.9% 88

                    
# Install missing packages
import sys
import subprocess

def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])

# Required packages
for package in ['wbdata', 'country_converter']:
try:
__import__(package)
except ImportError:
install(package)

# Import libraries
import wbdata
import country_converter as coco
from datetime import datetime

# Define World Bank indicator code
dataset_code = 'VC.IDP.NWDS'

# Download data from World Bank API
data = wbdata.get_dataframe({dataset_code: 'value'},
date=(datetime(1960, 1, 1), datetime.today()),
parse_dates=True,
keep_levels=True).reset_index()

# Extract year
data['year'] = data['date'].dt.year

# Convert country names to ISO codes using country_converter
cc = coco.CountryConverter()
data['iso2c'] = cc.convert(names=data['country'], to='ISO2', not_found=None)
data['iso3c'] = cc.convert(names=data['country'], to='ISO3', not_found=None)

# Filter out rows where ISO codes could not be matched — likely not real countries
data = data[data['iso2c'].notna() & data['iso3c'].notna()]

# Sort for calculation
data = data.sort_values(['iso3c', 'year'])

# Calculate YoY absolute and percent change
data['value_change'] = data.groupby('iso3c')['value'].diff()
data['value_change_percent'] = data.groupby('iso3c')['value'].pct_change() * 100

# Calculate ranks (higher GDP per capita = better rank)
data['rank'] = data.groupby('year')['value'].rank(ascending=False, method='dense')

# Calculate rank change from previous year
data['rank_change'] = data.groupby('iso3c')['rank'].diff()

# Select desired columns
final_df = data[['country', 'iso2c', 'iso3c', 'year', 'value',
'value_change', 'value_change_percent', 'rank', 'rank_change']].copy()

# Optional: Add labels as metadata (could be useful for export or UI)
column_labels = {
'country': 'Country name',
'iso2c': 'ISO 2-letter country code',
'iso3c': 'ISO 3-letter country code',
'year': 'Year',
'value': 'GDP per capita (current US$)',
'value_change': 'Year-over-Year change in value',
'value_change_percent': 'Year-over-Year percent change in value',
'rank': 'Country rank by GDP per capita (higher = richer)',
'rank_change': 'Change in rank from previous year'
}

# Display first few rows
print(final_df.head(10))

# Optional: Save to CSV
#final_df.to_csv("gdp_per_capita_cleaned.csv", index=False)
                    
                
                    
# Check and install required packages
required_packages <- c("WDI", "countrycode", "dplyr")

for (pkg in required_packages) {
  if (!requireNamespace(pkg, quietly = TRUE)) {
    install.packages(pkg)
  }
}

# Load the necessary libraries
library(WDI)
library(dplyr)
library(countrycode)

# Define the dataset code (World Bank indicator code)
dataset_code <- 'VC.IDP.NWDS'

# Download data using WDI package
dat <- WDI(indicator = dataset_code)

# Filter only countries using 'is_country' from countrycode
# This uses iso2c to identify whether the entry is a recognized country
dat <- dat %>%
  filter(countrycode(iso2c, origin = 'iso2c', destination = 'country.name', warn = FALSE) %in%
           countrycode::codelist$country.name.en)

# Ensure dataset is ordered by country and year
dat <- dat %>%
  arrange(iso3c, year)

# Rename the dataset_code column to "value" for easier manipulation
dat <- dat %>%
  rename(value = !!dataset_code)

# Calculate year-over-year (YoY) change and percentage change
dat <- dat %>%
  group_by(iso3c) %>%
  mutate(
    value_change = value - lag(value),                              # Absolute change from previous year
    value_change_percent = 100 * (value - lag(value)) / lag(value) # Percent change from previous year
  ) %>%
  ungroup()

# Calculate rank by year (higher value => higher rank)
dat <- dat %>%
  group_by(year) %>%
  mutate(rank = dense_rank(desc(value))) %>% # Rank countries by descending value
  ungroup()

# Calculate rank change (positive = moved up, negative = moved down)
dat <- dat %>%
  group_by(iso3c) %>%
  mutate(rank_change = rank - lag(rank)) %>% # Change in rank compared to previous year
  ungroup()

# Select and reorder final columns
final_data <- dat %>%
  select(
    country,
    iso2c,
    iso3c,
    year,
    value,
    value_change,
    value_change_percent,
    rank,
    rank_change
  )

# Add labels (variable descriptions)
attr(final_data$country, "label") <- "Country name"
attr(final_data$iso2c, "label") <- "ISO 2-letter country code"
attr(final_data$iso3c, "label") <- "ISO 3-letter country code"
attr(final_data$year, "label") <- "Year"
attr(final_data$value, "label") <- "GDP per capita (current US$)"
attr(final_data$value_change, "label") <- "Year-over-Year change in value"
attr(final_data$value_change_percent, "label") <- "Year-over-Year percent change in value"
attr(final_data$rank, "label") <- "Country rank by GDP per capita (higher = richer)"
attr(final_data$rank_change, "label") <- "Change in rank from previous year"

# Print the first few rows of the final dataset
print(head(final_data, 10))