README
Source on GitHubA Julia port of the R countrycode
package. Convert between country coding schemes (ISO, CoW, Polity, IMF, WB,
V-Dem, Eurostat, …) and standardize multilingual country names.
Status: pre-release. API may change.
Quick start
using Pkg
Pkg.add(url="https://github.com/angrahed/CountryCodes.jl") # TODO: update once registered
using CountryCodes
countrycode("USA", :iso3c => :cown) # -> 2
countrycode(["USA", "DZA"], :iso3c => :cown) # -> [2, 615]
countrycode("Albania", :country_name_en => :iso3c) # -> "ALB"
countrycode("Congo-Kinshasa", :country_name_en => :iso3c) # -> "COD"
standardize_name("Deutschland") # -> "Germany"
guess_field(["USA", "CAN", "MEX"]) # -> :iso3cTables.jl integration
Works with any Tables.jl-compatible input — DataFrame, DuckDB.DBInterface
results, CSV.File, Arrow.Table, named tuples of vectors, … Lookup runs
once per unique source value, not once per row.
using DataFrames, CountryCodes
df = DataFrame(iso3c = ["USA", "DZA", "FRA"])
# Out-of-place: returns a column-table that round-trips to your input type.
DataFrame(add_country_codes(df, :iso3c => :cown))
# 3×2 DataFrame iso3c=[USA,DZA,FRA] cown=[2,615,220]
# In-place on a DataFrame:
add_country_codes!(df, :iso3c => [(:cow_code => :cown),
(:name => :country_name_en)])10,000-row ISO3 → CoW conversion completes in well under 1ms after warmup.
Why GPL-3?
The upstream R countrycode package is GPL-3 licensed and we redistribute its
data verbatim, so this port is also GPL-3. If you need a permissive-licensed
package that only covers ISO codes, see Countries.jl.
Comparison
| Package | Schemes | License | Name regex matching | Panel data |
|---|---|---|---|---|
| CountryCodes.jl | 40+ (ISO, CoW, Polity, IMF, …) | GPL-3.0 | Yes | Yes |
| Countries.jl | ISO only | MIT | No | No |
Documentation
See docs/src/ for now. Hosted docs land in Phase 11.
License
GPL-3.0-or-later. See LICENSE.