Skip to content

Commit

Permalink
Add colombian products
Browse files Browse the repository at this point in the history
  • Loading branch information
makmanalp committed Aug 5, 2015
1 parent 97e1652 commit fc5445b
Show file tree
Hide file tree
Showing 9 changed files with 4,026 additions and 1 deletion.
3 changes: 3 additions & 0 deletions product/HS/Colombia_Prospedia/README.md
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)
3 changes: 3 additions & 0 deletions product/HS/Colombia_Prospedia/Tupfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CLEAN = PYTHONPATH=../../../ python2.7 -B clean.py

: in/* |> $(CLEAN) |> out/products_colombia_prospedia.csv out/products_colombia_prospedia.dta
37 changes: 37 additions & 0 deletions product/HS/Colombia_Prospedia/clean.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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/HS_hierarchy_master - Names.tsv", encoding="utf-8", dtype={"code": str})

hierarchy = pd.read_table("./in/HS_hierarchy_master - Hierarchy.tsv",
encoding="utf-8",
dtype={
"4digit": str,
"2digit": str,
"prosperia_section": str,
"section": str,
})
hierarchy.columns = ["4digit_code", "2digit_code", "prosperia_section_code", "atlas_section"]
hierarchy["4digit_name"] = None
hierarchy["2digit_name"] = None
hierarchy["prosperia_section_name"] = None


h = Hierarchy(["prosperia_section", "2digit", "4digit"])
parent_code_table = repeated_table_to_parent_id_table(hierarchy, h)

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

from IPython import embed; embed()

c = Classification(parent_id_table, h)

c.to_csv("out/products_mexico_prospedia.csv")
c.to_stata("out/products_mexico_prospedia.dta")
Loading

0 comments on commit fc5445b

Please sign in to comment.