Patent applications, nonresidents

Source: worldbank.org, 01.09.2025

Year: 2021

Flag Country Value Value change, % Rank
Albania Albania 1 0% 98
Andorra Andorra 8 +60% 91
United Arab Emirates United Arab Emirates 2,354 +25.9% 27
Argentina Argentina 3,263 +27.4% 23
Armenia Armenia 8 +14.3% 91
Antigua & Barbuda Antigua & Barbuda 8 +167% 91
Australia Australia 29,443 +9.35% 7
Austria Austria 175 +1.16% 59
Azerbaijan Azerbaijan 16 -11.1% 84
Belgium Belgium 415 +44.1% 44
Bangladesh Bangladesh 373 +3.04% 46
Bulgaria Bulgaria 6 -14.3% 93
Bahrain Bahrain 326 +26.8% 48
Bosnia & Herzegovina Bosnia & Herzegovina 8 +60% 91
Belarus Belarus 110 +42.9% 66
Belize Belize 27 +17.4% 79
Bolivia Bolivia 227 +50.3% 55
Brazil Brazil 19,566 +2.67% 9
Brunei Brunei 137 +19.1% 63
Bhutan Bhutan 7 +16.7% 92
Canada Canada 32,445 +7.74% 6
Switzerland Switzerland 267 -11.3% 51
Chile Chile 2,680 +10.2% 24
China China 159,019 +4.38% 2
Colombia Colombia 1,855 +5.88% 29
Cape Verde Cape Verde 1 -75% 98
Costa Rica Costa Rica 566 +8.02% 40
Cuba Cuba 86 +13.2% 69
Cyprus Cyprus 2 +100% 97
Czechia Czechia 59 +5.36% 72
Germany Germany 18,747 -5.53% 10
Djibouti Djibouti 10 +100% 89
Dominica Dominica 11 +450% 88
Denmark Denmark 186 -14.3% 58
Dominican Republic Dominican Republic 220 +6.28% 56
Algeria Algeria 581 +6.22% 38
Ecuador Ecuador 373 -0.267% 46
Egypt Egypt 1,343 +9.28% 33
Spain Spain 126 +1.61% 64
Estonia Estonia 1 -50% 98
Finland Finland 105 +8.25% 67
France France 1,373 -11% 32
United Kingdom United Kingdom 7,263 -16.1% 19
Georgia Georgia 164 +22.4% 60
Gambia Gambia 91 +37.9% 68
Greece Greece 532 +46.6% 41
Grenada Grenada 16 0% 84
Guatemala Guatemala 249 +21.5% 53
Hong Kong SAR China Hong Kong SAR China 21,542 +1.94% 8
Honduras Honduras 188 +0.535% 57
Croatia Croatia 11 -8.33% 88
Hungary Hungary 13 -53.6% 86
Indonesia Indonesia 7,403 +8.06% 17
India India 35,306 +4.98% 5
Ireland Ireland 42 -22.2% 74
Iran Iran 581 -8.36% 38
Iceland Iceland 2 -33.3% 97
Israel Israel 8,017 +23.7% 15
Italy Italy 797 -15.8% 35
Jamaica Jamaica 60 +27.7% 71
Jordan Jordan 322 +6.98% 49
Japan Japan 66,748 +9.2% 3
Kenya Kenya 37 +5.71% 75
Kyrgyzstan Kyrgyzstan 4 +300% 95
South Korea South Korea 51,753 +11.8% 4
Sri Lanka Sri Lanka 273 +8.76% 50
Lithuania Lithuania 9 -50% 90
Luxembourg Luxembourg 1,441 +112% 30
Latvia Latvia 4 +300% 95
Macao SAR China Macao SAR China 35 -44.4% 76
Morocco Morocco 2,549 +4.55% 26
Monaco Monaco 3 -57.1% 96
Moldova Moldova 12 +9.09% 87
Madagascar Madagascar 22 +4.76% 80
Mexico Mexico 15,044 +14.1% 11
Malta Malta 5 0% 94
Mongolia Mongolia 77 -6.1% 70
Mozambique Mozambique 16 +14.3% 84
Mauritius Mauritius 14 -26.3% 85
Malaysia Malaysia 6,651 +13.9% 20
Netherlands Netherlands 1,390 +68.5% 31
Norway Norway 634 +12.4% 37
New Zealand New Zealand 6,522 +20.4% 21
Oman Oman 511 -1.54% 42
Pakistan Pakistan 567 +0.89% 39
Panama Panama 401 +35% 45
Peru Peru 1,141 -0.0876% 34
Philippines Philippines 3,903 +11% 22
Papua New Guinea Papua New Guinea 29 -45.3% 77
Poland Poland 111 +26.1% 65
Portugal Portugal 42 -84% 74
Paraguay Paraguay 354 +9.6% 47
Qatar Qatar 722 +19.5% 36
Romania Romania 45 -4.26% 73
Russia Russia 11,408 +1.63% 13
Rwanda Rwanda 2 +100% 97
Saudi Arabia Saudi Arabia 2,581 +13.5% 25
Singapore Singapore 12,566 +9.39% 12
El Salvador El Salvador 144 +0.699% 62
San Marino San Marino 722 +1.83% 36
Serbia Serbia 18 +125% 82
São Tomé & Príncipe São Tomé & Príncipe 14 0% 85
Slovakia Slovakia 13 -13.3% 86
Slovenia Slovenia 17 +41.7% 83
Sweden Sweden 425 -1.62% 43
Seychelles Seychelles 28 +211% 78
Syria Syria 20 +25% 81
Thailand Thailand 7,375 +10.7% 18
Tonga Tonga 2 -33.3% 97
Trinidad & Tobago Trinidad & Tobago 149 +34.2% 61
Turkey Turkey 242 +1.68% 54
Tuvalu Tuvalu 11 +10% 88
Uganda Uganda 4 -33.3% 95
Ukraine Ukraine 2,091 +14.8% 28
United States United States 329,229 +0.502% 1
Uzbekistan Uzbekistan 252 +8.62% 52
St. Vincent & Grenadines St. Vincent & Grenadines 11 +120% 88
Vietnam Vietnam 7,468 +11.9% 16
Yemen Yemen 22 +175% 80
South Africa South Africa 9,156 +49% 14
Zambia Zambia 13 +30% 86

                    
# 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 = 'IP.PAT.NRES'

# 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 <- 'IP.PAT.NRES'

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