Annual freshwater withdrawals, domestic (% of total freshwater withdrawal)

Source: worldbank.org, 03.09.2025

Year: 2021

Flag Country Value Value change, % Rank
Afghanistan Afghanistan 0.998 0% 178
Angola Angola 45.3 0% 44
Albania Albania 27.9 -2.57% 68
United Arab Emirates United Arab Emirates 53.6 +1.55% 33
Argentina Argentina 15.5 0% 107
Armenia Armenia 20.3 -12.2% 91
Antigua & Barbuda Antigua & Barbuda 62.6 0% 20
Australia Australia 14 -17.6% 116
Austria Austria 25.7 0% 74
Azerbaijan Azerbaijan 3.15 -10.9% 170
Burundi Burundi 15.4 0% 108
Belgium Belgium 16.7 0% 103
Benin Benin 62 0% 23
Burkina Faso Burkina Faso 45.9 0% 42
Bangladesh Bangladesh 10 0% 141
Bulgaria Bulgaria 16.9 +2.17% 101
Bahrain Bahrain 63.4 0% 17
Belarus Belarus 42 +1.76% 48
Belize Belize 11.3 0% 131
Bolivia Bolivia 11.5 -1.46% 130
Brazil Brazil 24.2 +0.641% 84
Barbados Barbados 24.7 0% 79
Brunei Brunei 165 0% 1
Bhutan Bhutan 5.03 0% 162
Botswana Botswana 54.8 +10.7% 31
Central African Republic Central African Republic 82.9 0% 9
Canada Canada 14.4 0% 112
Switzerland Switzerland 53.2 -1.24% 34
Chile Chile 3.99 0% 167
China China 20.1 0% 92
Côte d’Ivoire Côte d’Ivoire 27.5 0% 69
Cameroon Cameroon 22.7 0% 86
Congo - Kinshasa Congo - Kinshasa 68 0% 14
Congo - Brazzaville Congo - Brazzaville 69.5 0% 13
Colombia Colombia 12.2 -2.59% 126
Comoros Comoros 48 0% 40
Cape Verde Cape Verde 55.3 -7.21% 29
Costa Rica Costa Rica 32.2 +21.8% 62
Cuba Cuba 24.4 0% 82
Cyprus Cyprus 37.7 +0.699% 54
Czechia Czechia 46.5 +0.938% 41
Germany Germany 41.5 0% 49
Djibouti Djibouti 84.2 0% 8
Dominica Dominica 95 0% 5
Denmark Denmark 41 0% 50
Dominican Republic Dominican Republic 9.42 0% 144
Algeria Algeria 34.4 0% 59
Ecuador Ecuador 13 0% 124
Egypt Egypt 13.9 0% 117
Eritrea Eritrea 5.33 0% 160
Spain Spain 15.7 0% 106
Estonia Estonia 7.21 -2.3% 154
Ethiopia Ethiopia 7.68 0% 150
Finland Finland 14.3 0% 114
Fiji Fiji 29.8 0% 63
France France 21.7 0% 88
Gabon Gabon 60.9 0% 25
United Kingdom United Kingdom 74 0% 11
Georgia Georgia 33.2 -9.42% 61
Ghana Ghana 20.5 0% 90
Guinea Guinea 25.8 0% 73
Gambia Gambia 40.6 0% 51
Guinea-Bissau Guinea-Bissau 17.9 0% 99
Equatorial Guinea Equatorial Guinea 79.8 0% 10
Greece Greece 16.7 +0.347% 102
Grenada Grenada 85.1 0% 7
Guatemala Guatemala 25.1 0% 78
Guyana Guyana 4.24 0% 166
Honduras Honduras 19.6 0% 94
Croatia Croatia 43.9 +2.19% 47
Haiti Haiti 13.1 0% 121
Hungary Hungary 14.1 0% 115
Indonesia Indonesia 10.7 0% 134
India India 7.36 0% 153
Ireland Ireland 64 +0.0779% 16
Iran Iran 6.65 0% 157
Iraq Iraq 15.9 -16% 105
Iceland Iceland 28.7 0% 66
Israel Israel 38.2 -8.4% 53
Italy Italy 27.1 0% 71
Jamaica Jamaica 73.4 +1.7% 12
Jordan Jordan 45 0% 45
Japan Japan 18.9 0% 95
Kazakhstan Kazakhstan 18.8 0% 96
Kenya Kenya 12.3 0% 125
Kyrgyzstan Kyrgyzstan 2.92 0% 171
Cambodia Cambodia 4.49 0% 165
St. Kitts & Nevis St. Kitts & Nevis 98.7 0% 4
South Korea South Korea 24.6 0% 80
Kuwait Kuwait 35.9 0% 57
Laos Laos 1.77 0% 175
Lebanon Lebanon 13 0% 123
Liberia Liberia 55 0% 30
Libya Libya 12 0% 127
St. Lucia St. Lucia 29.1 0% 65
Sri Lanka Sri Lanka 6.22 0% 158
Lesotho Lesotho 45.7 0% 43
Lithuania Lithuania 53.8 0% 32
Luxembourg Luxembourg 100 0% 2
Latvia Latvia 48.9 0% 38
Morocco Morocco 10.2 0% 139
Monaco Monaco 100 0% 2
Moldova Moldova 20.1 +0.251% 93
Madagascar Madagascar 2.91 0% 172
Maldives Maldives 94.9 0% 6
Mexico Mexico 14.8 +0.49% 111
North Macedonia North Macedonia 13.7 -60.6% 118
Mali Mali 2.06 0% 174
Malta Malta 61.7 +2.03% 24
Myanmar (Burma) Myanmar (Burma) 9.95 0% 142
Montenegro Montenegro 59.9 0% 26
Mongolia Mongolia 9.8 0% 143
Mozambique Mozambique 25.3 0% 77
Mauritania Mauritania 7.07 0% 155
Mauritius Mauritius 48.8 +0.838% 39
Malawi Malawi 10.5 0% 135
Malaysia Malaysia 24.5 0% 81
Namibia Namibia 25.3 0% 76
Niger Niger 7.48 0% 151
Nigeria Nigeria 40.1 0% 52
Nicaragua Nicaragua 14.9 0% 110
Netherlands Netherlands 25.5 +3.01% 75
Norway Norway 27.5 -3.85% 70
Nepal Nepal 1.55 0% 176
New Zealand New Zealand 10.2 0% 138
Oman Oman 6.79 0% 156
Pakistan Pakistan 5.26 0% 161
Panama Panama 62.7 0% 19
Peru Peru 5.81 0% 159
Philippines Philippines 10.3 +0.413% 137
Papua New Guinea Papua New Guinea 57 0% 27
Poland Poland 21.3 +0.387% 89
Puerto Rico Puerto Rico 24.3 0% 83
North Korea North Korea 10.4 0% 136
Portugal Portugal 14.4 0% 113
Paraguay Paraguay 15 0% 109
Palestinian Territories Palestinian Territories 56.4 +28% 28
Qatar Qatar 62.4 +5.49% 21
Romania Romania 16.1 +10.8% 104
Russia Russia 26.5 0% 72
Rwanda Rwanda 37.7 -1.56% 55
Saudi Arabia Saudi Arabia 13.1 0% 122
Sudan Sudan 3.53 0% 169
Senegal Senegal 8.64 0% 147
Singapore Singapore 45 0% 46
Sierra Leone Sierra Leone 52.3 0% 36
El Salvador El Salvador 34.7 -14.2% 58
Somalia Somalia 0.455 0% 179
Serbia Serbia 13.6 +6.96% 119
South Sudan South Sudan 29.3 0% 64
São Tomé & Príncipe São Tomé & Príncipe 35.9 0% 56
Suriname Suriname 8 0% 149
Slovakia Slovakia 52.7 -0.168% 35
Slovenia Slovenia 18.6 +9.74% 97
Sweden Sweden 33.8 +20.1% 60
Eswatini Eswatini 3.87 0% 168
Seychelles Seychelles 65.7 0% 15
Syria Syria 8.8 0% 146
Chad Chad 11.8 0% 129
Togo Togo 63.1 0% 18
Thailand Thailand 4.78 0% 164
Tajikistan Tajikistan 9.21 0% 145
Turkmenistan Turkmenistan 2.61 +51% 173
Timor-Leste Timor-Leste 8.45 0% 148
Trinidad & Tobago Trinidad & Tobago 62 0% 22
Tunisia Tunisia 22.7 0% 85
Turkey Turkey 11.8 +6.29% 128
Tanzania Tanzania 10.2 0% 140
Uganda Uganda 51.5 0% 37
Ukraine Ukraine 28.1 +0.0101% 67
Uruguay Uruguay 11.2 0% 132
United States United States 13.1 0% 120
Uzbekistan Uzbekistan 4.95 +12% 163
St. Vincent & Grenadines St. Vincent & Grenadines 100 0% 3
Venezuela Venezuela 22.6 0% 87
Vietnam Vietnam 1.47 0% 177
Yemen Yemen 7.43 0% 152
South Africa South Africa 17.4 +7.58% 100
Zambia Zambia 18.4 0% 98
Zimbabwe Zimbabwe 11.1 0% 133

                    
# 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 = 'ER.H2O.FWDM.ZS'

# 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 <- 'ER.H2O.FWDM.ZS'

# 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))