-
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 livestock classification for colombia rural.
- Loading branch information
Showing
9 changed files
with
71 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,3 @@ | ||
This is basically HS92, with names generously translated by Ryan. | ||
|
||
[here](https://docs.google.com/spreadsheets/d/1yLhTZ6cV6aWLJkJmAQGRIEGKFSEeF_dwMtCA3YagOzI/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_livestock.py | ||
|
||
: in/* |> $(CLEAN) |> out/livestock.csv out/livestock.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,34 @@ | ||
import pandas as pd | ||
|
||
from classification import (Hierarchy, repeated_table_to_parent_id_table, | ||
parent_code_table_to_parent_id_table, | ||
Classification) | ||
|
||
if __name__ == "__main__": | ||
names = pd.read_table("./in/Livestock - Names.tsv", encoding="utf-8", | ||
dtype={"code": str}) | ||
|
||
hierarchy = pd.read_table("./in/Livestock - Hierarchy.tsv", encoding="utf-8") | ||
hierarchy.columns = ["level1_code", "level0_code"] | ||
|
||
fields = { | ||
"level0": [], | ||
"level1": [] | ||
} | ||
|
||
h = Hierarchy(["level0", "level1"]) | ||
parent_code_table = repeated_table_to_parent_id_table(hierarchy, h, fields) | ||
parent_code_table.code = parent_code_table.code.astype(str) | ||
|
||
parent_code_table = parent_code_table.merge(names, on=["code", "level"]) | ||
|
||
parent_id_table = parent_code_table_to_parent_id_table(parent_code_table, h) | ||
parent_id_table["name"] = parent_id_table.name_en | ||
|
||
parent_id_table = parent_id_table[["code", "name", "level", "name_en", | ||
"name_es", "parent_id"]] | ||
|
||
c = Classification(parent_id_table, h) | ||
|
||
c.to_csv("out/livestock.csv") | ||
c.to_stata("out/livestock.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,9 @@ | ||
level1 level0 | ||
buffalos total | ||
equines total | ||
fisheries total | ||
fishing total | ||
goats total | ||
pigs total | ||
poultry total | ||
sheep total |
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 level name_en name_es | ||
total level0 Total Total | ||
buffalos level1 Buffaloes Búfalos | ||
equines level1 Equines Equinos | ||
fisheries level1 Fisheries Fisheries | ||
fishing level1 Fishing Fishing | ||
goats level1 Goats Goats | ||
pigs level1 Pigs Pigs | ||
poultry level1 Poultry Poultry | ||
sheep level1 Sheep Sheep |
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","level","name_en","name_es","parent_id" | ||
0,"total","Total","level0","Total","Total","" | ||
1,"buffalos","Buffaloes","level1","Buffaloes","Búfalos",0.0 | ||
2,"equines","Equines","level1","Equines","Equinos",0.0 | ||
3,"fisheries","Fisheries","level1","Fisheries","Fisheries",0.0 | ||
4,"fishing","Fishing","level1","Fishing","Fishing",0.0 | ||
5,"goats","Goats","level1","Goats","Goats",0.0 | ||
6,"pigs","Pigs","level1","Pigs","Pigs",0.0 | ||
7,"poultry","Poultry","level1","Poultry","Poultry",0.0 | ||
8,"sheep","Sheep","level1","Sheep","Sheep",0.0 |
Binary file not shown.
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