-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add international atlas country codes from COMTRADE.
- Loading branch information
Showing
8 changed files
with
563 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
The classification for the international atlas. This is based on the | ||
conventions of the COMTRADE data. | ||
|
||
https://docs.google.com/spreadsheets/d/1Kg1-J1C0EYWTTPJA-Cs4fd4AyAJ8AZeCoubpnLfRWn4/edit#gid=0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CLEAN = PYTHONPATH=../../../ python2.7 -B clean.py | ||
|
||
: in/* |> $(CLEAN) |> out/locations_international_atlas.csv out/locations_international_atlas.dta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pandas as pd | ||
|
||
from classification import (Hierarchy, parent_code_table_to_parent_id_table, | ||
Classification) | ||
|
||
if __name__ == "__main__": | ||
|
||
df = pd.read_csv("./in/International Atlas Location Codes - Clean Countries.csv", | ||
encoding="utf-8", | ||
dtype={"parent_code": str} | ||
)\ | ||
.drop("comtrade_name", axis=1) | ||
df["level"] = "country" | ||
|
||
regions = pd.read_csv("./in/International Atlas Location Codes - Continents and Regions.csv", encoding="utf-8") | ||
regions["name_short_en"] = regions["name_en"] | ||
regions["name_short_es"] = regions["name_es"] | ||
regions["level"] = "region" | ||
regions["code"] = regions["code"].astype(unicode) | ||
|
||
df = pd.concat([df, regions]).reset_index(drop=True) | ||
|
||
h = Hierarchy(["region", "country"]) | ||
parent_id_table = parent_code_table_to_parent_id_table(df, h) | ||
parent_id_table["name"] = parent_id_table["name_en"] | ||
|
||
c = Classification(parent_id_table, h) | ||
c.to_csv("out/locations_international_atlas.csv") | ||
c.to_stata("out/locations_international_atlas.dta") |
253 changes: 253 additions & 0 deletions
253
location/International/Atlas/in/International Atlas Location Codes - Clean Countries.csv
Large diffs are not rendered by default.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
...on/International/Atlas/in/International Atlas Location Codes - Continents and Regions.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
code,name_en,name_es,level,parent_code | ||
1,Africa,África,region, | ||
2,Asia,Asia,region, | ||
3,Oceania,Oceanía,region, | ||
4,Europe,Europa,region, | ||
5,North America,Norteamérica,region, | ||
6,South America,Sudamérica,region, | ||
7,Central America ,Centroamérica,region, | ||
8,Carribean,Caribe,region, | ||
9,Other,Otro,region, |
262 changes: 262 additions & 0 deletions
262
location/International/Atlas/out/locations_international_atlas.csv
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters