j4ckofalltrades commited on
Commit
f729b9b
·
verified ·
1 Parent(s): 15cdd89

Add open customs data

Browse files
README.md ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ tags:
5
+ - trade
6
+ - customs
7
+ - philippines
8
+ - economics
9
+ - government
10
+ - imports
11
+ size_categories:
12
+ - 10M<n<100M
13
+ ---
14
+
15
+ # Open Customs Data
16
+
17
+ ## Dataset Summary
18
+
19
+ This dataset contains **20,255,360 import transactions** from the Bureau of Customs of the Philippines spanning from **2012 to 2019**. It represents a comprehensive record of goods imported into the Philippines, including detailed information on product classifications, values, duties paid, countries of origin, and ports of entry.
20
+
21
+ The data was extracted from the Bureau of Customs' electronic2mobile (e2m) system and has been cleaned and standardized for research purposes. This "lite" version contains 30 variables selected from the original 52 variables in the complete dataset, focusing on the most analytically useful fields while excluding sensitive information such as importer identities.
22
+
23
+ ## Languages
24
+
25
+ The dataset is primarily in English (`en`).
26
+
27
+ ## Dataset Structure
28
+
29
+ ### Data Instances
30
+
31
+ The dataset is split into 8 CSV files, one for each year from 2012 to 2019.
32
+
33
+ ```json
34
+ {
35
+ "uid": "2012q1 00000001",
36
+ "ty": 2012,
37
+ "tq": "2012q1",
38
+ "tm": null,
39
+ "entry": "C",
40
+ "hscode": "15119090000",
41
+ "goodsdescription": "PALM OLEIN IN BULK",
42
+ "p": 0.97359568,
43
+ "q": 2499867,
44
+ "m_fob": 2433859.8,
45
+ "m_cif": 2486856.3,
46
+ "fx_usd": 1,
47
+ "dutiablevalueforeign": 2486856.15,
48
+ "exchangerate": 43.921,
49
+ "currency": "USD",
50
+ "dutiablevaluephp": 109225209,
51
+ "dutypaid": 0,
52
+ "exciseadvalorem": 0,
53
+ "arrastre": 274985,
54
+ "wharfage": null,
55
+ "vatbase": 112934962,
56
+ "vatpaid": 13552195,
57
+ "othertax": null,
58
+ "finesandpenalties": null,
59
+ "dutiestaxes": 13552195,
60
+ "prefcode": "AFTA",
61
+ "countryorigin_iso3": "MYS",
62
+ "countryexport_iso3": "MYS",
63
+ "subport": null,
64
+ "port": null
65
+ }
66
+ ```
67
+
68
+ ### Data Fields
69
+
70
+ | Field | Description | Data Type |
71
+ |-------|-------------|-----------|
72
+ | `uid` | Unique identifier for each transaction (format: YYYYqQ XXXXXXXX) | string |
73
+ | `ty` | Transaction year (2012-2019) | integer |
74
+ | `tq` | Transaction quarter (e.g., "2012q1") | string |
75
+ | `tm` | Transaction month | string |
76
+ | `entry` | Entry type: C (Consumption), W (Warehousing), T (Transshipment), C-Temp (Consumption-Temporary) | string |
77
+ | `hscode` | 11-digit ASEAN Harmonized Tariff Nomenclature (AHTN) code | string |
78
+ | `goodsdescription` | Text description of the imported goods | string |
79
+ | `p` | Unit price (dutiable value / quantity) in USD | float |
80
+ | `q` | Quantity of goods imported | float |
81
+ | `m_fob` | Free on Board value in USD | float |
82
+ | `m_cif` | Cost, Insurance, and Freight value in USD | float |
83
+ | `fx_usd` | Exchange rate to convert foreign currency to USD | float |
84
+ | `dutiablevalueforeign` | Dutiable value in foreign currency | float |
85
+ | `exchangerate` | Exchange rate to convert to Philippine Peso | float |
86
+ | `currency` | Original currency code of the transaction | string |
87
+ | `dutiablevaluephp` | Dutiable value in Philippine Peso | float |
88
+ | `dutypaid` | Customs duty paid in PHP | float |
89
+ | `exciseadvalorem` | Ad valorem excise tax paid in PHP | float |
90
+ | `arrastre` | Arrastre (cargo handling) charges in PHP | float |
91
+ | `wharfage` | Wharfage fees in PHP | float |
92
+ | `vatbase` | Base amount for VAT computation in PHP | float |
93
+ | `vatpaid` | Value Added Tax paid in PHP | float |
94
+ | `othertax` | Other taxes paid in PHP | float |
95
+ | `finesandpenalties` | Fines and penalties assessed in PHP | float |
96
+ | `dutiestaxes` | Total duties and taxes paid in PHP | float |
97
+ | `prefcode` | Preferential trade agreement code (e.g., AFTA, ACFTA, JPEPA, AKFTA, AANZFTA, PJEPA, AIFTA, GSP) | string |
98
+ | `countryorigin_iso3` | ISO 3166-1 alpha-3 code for country of origin | string |
99
+ | `countryexport_iso3` | ISO 3166-1 alpha-3 code for country of export | string |
100
+ | `subport` | Subport of entry code | string |
101
+ | `port` | Port of entry code | string |
102
+
103
+ ### Data Splits
104
+
105
+ The dataset is provided as yearly splits without predefined train/validation/test splits to allow researchers flexibility in their analysis:
106
+
107
+ | Year | File | Size | Transactions |
108
+ |------|------|------|--------------|
109
+ | 2012 | boc_lite_2012.csv | 196 MB | 1,193,628 |
110
+ | 2013 | boc_lite_2013.csv | 206 MB | 1,225,431 |
111
+ | 2014 | boc_lite_2014.csv | 260 MB | 1,421,241 |
112
+ | 2015 | boc_lite_2015.csv | 471 MB | 2,236,612 |
113
+ | 2016 | boc_lite_2016.csv | 657 MB | 3,140,436 |
114
+ | 2017 | boc_lite_2017.csv | 717 MB | 3,490,131 |
115
+ | 2018 | boc_lite_2018.csv | 644 MB | 3,753,118 |
116
+ | 2019 | boc_lite_2019.csv | 671 MB | 3,794,763 |
117
+ | **Total** | | **3.8 GB** | **20,255,360** |
118
+
119
+ ### Parquet Files
120
+
121
+ The dataset is also available in Apache Parquet format for improved query performance and reduced storage. Two formats are provided:
122
+
123
+ #### Single Combined File
124
+
125
+ `boc_lite_combined.parquet` contains all 20+ million transactions in a single file (~1.4 GB).
126
+
127
+ **Best for:** Full dataset queries, cross-year analysis, and environments where a single file is preferred.
128
+
129
+ ```python
130
+ # Python - Polars
131
+ import polars as pl
132
+ df = pl.read_parquet('boc_lite_combined.parquet')
133
+
134
+ # Python - Pandas
135
+ import pandas as pd
136
+ df = pd.read_parquet('boc_lite_combined.parquet')
137
+
138
+ # DuckDB
139
+ SELECT * FROM 'boc_lite_combined.parquet' WHERE ty = 2015 LIMIT 10;
140
+ ```
141
+
142
+ #### Yearly Parquet Files
143
+
144
+ `boc_lite_partitioned/` contains separate parquet files for each year.
145
+
146
+ | File | Size |
147
+ |------|------|
148
+ | 2012.parquet | 86 MB |
149
+ | 2013.parquet | 89 MB |
150
+ | 2014.parquet | 105 MB |
151
+ | 2015.parquet | 156 MB |
152
+ | 2016.parquet | 222 MB |
153
+ | 2017.parquet | 252 MB |
154
+ | 2018.parquet | 268 MB |
155
+ | 2019.parquet | 273 MB |
156
+
157
+ **Best for:** Year-specific queries, incremental processing, and memory-constrained environments.
158
+
159
+ ```python
160
+ # Read all years
161
+ df = pl.read_parquet('boc_lite_partitioned/*.parquet')
162
+
163
+ # Read specific year
164
+ df_2015 = pl.read_parquet('boc_lite_partitioned/2015.parquet')
165
+ ```
166
+
167
+ ## Dataset Creation
168
+
169
+ ### Source Data
170
+
171
+ #### Initial Data Collection and Normalization
172
+
173
+ The data was extracted from the Bureau of Customs' electronic2mobile (e2m) system, which is the official electronic customs processing system in the Philippines.
174
+
175
+ ### Annotations
176
+
177
+ This dataset does not contain additional annotations beyond the original customs declaration data.
178
+ ### Parquet Aggregation
179
+
180
+ The Parquet files were generated from the original CSV files using Polars (>=0.20.0) with the following process:
181
+
182
+ 1. **Schema normalization:** Explicit schema overrides ensure consistent data types across all years, addressing discrepancies in how columns were typed in different yearly files:
183
+ - Numeric fields (`p`, `q`, `m_fob`, `m_cif`, `dutiablevalueforeign`, `exchangerate`, `dutiablevaluephp`, `dutypaid`, `exciseadvalorem`, `arrastre`, `wharfage`, `vatbase`, `vatpaid`, `othertax`, `finesandpenalties`, `dutiestaxes`) are normalized to `Float64`
184
+ - The `hscode` field is kept as `String` to preserve leading zeros in tariff codes
185
+ - The `ty` (transaction year) field is normalized to `Int64`
186
+
187
+ 2. **Character encoding:** UTF-8 lossy encoding is applied to handle invalid byte sequences present in some source records, replacing malformed characters rather than failing on read
188
+
189
+ 3. **Ragged line handling:** Lines with inconsistent column counts are truncated to match the expected schema, ensuring robust parsing of the source data
190
+
191
+ 4. **Streaming aggregation:** Lazy evaluation and streaming writes (`sink_parquet`) are used to process the full dataset without loading all 20+ million rows into memory
192
+
193
+ 5. **Compression:** Snappy compression is applied, achieving approximately 63% size reduction compared to the original CSV files (from ~3.8 GB to ~1.4 GB)
194
+
195
+ 6. **Partitioning:** For the partitioned output, data is filtered by transaction year (`ty`) and written to separate yearly files (`YYYY.parquet`)
196
+
197
+ 7. **Statistics:** Column statistics are embedded in the Parquet files to enable predicate pushdown and query optimization
198
+
199
+ ## Additional Information
200
+
201
+ ### Citation Information
202
+
203
+ Abante, Ken. (2020). An Open Data Set of Twenty Million Import Transactions from the Bureau of Customs of the Philippines (2012-2019). 10.13140/RG.2.2.24053.73444.
boc_lite_2012.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b1d65edd6cff3251f6feee7cbbf2ecad69614b8794b5780928d7a00cd9002f39
3
+ size 205315314
boc_lite_2013.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db3da40749600046327d67abcaa17bfae54834e9f1ac652ab2597606884201fc
3
+ size 215440518
boc_lite_2014.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:086a824b5d8a289cdc7edfce216628d3d675c620ec72cde6a3a058d0ec4cf7f7
3
+ size 272346660
boc_lite_2015.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b3b5a3a95340179a716a05611d51ad4906484d38363d1ac36494a404c04e4370
3
+ size 493501185
boc_lite_2016.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7de101ee40cc5f7649d28b239e07c320ca87e6d760fac3af170d65b3d61032e6
3
+ size 688475758
boc_lite_2017.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:21e80159f92bdb988a72baa06fa018785fe85a1bf54edf881f6db25edf4e16c9
3
+ size 750825160
boc_lite_2018.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2f65e1a6670b6af63af6cc066ce1c42fba40154d9bc5dacf7e610b6493551efc
3
+ size 675270173
boc_lite_2019.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:56a3c0d03cc5607400613187c42b8f41704c486b78fa326fa66d567e9b0e554d
3
+ size 703284232
boc_lite_combined.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7234628477b92557327b104f55736c784033a68c9836b59c2ac8a71f7f427915
3
+ size 1517123435
boc_lite_partitioned/2012.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:dd858e08a09e78bca2f3d45157dc7cf6b820018444f0b1da7cb8231687115be4
3
+ size 89629065
boc_lite_partitioned/2013.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1ac3620e3ea8de635b153fc9f79670d0d703007fb9bee6737ca6489270fede68
3
+ size 93222282
boc_lite_partitioned/2014.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a0c4cfa7b41423c73834c14c0a8b75b9c1140e4fc1597e2fde6d1aa994c7dddc
3
+ size 109933234
boc_lite_partitioned/2015.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2144b02491c4a9866dd33ec9fdf50b21af3648132714d6dd5e67f358469b74b9
3
+ size 162662866
boc_lite_partitioned/2016.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e609c82ec89d6266de0946df06f71d6268f39d4850c0a4888b3c03cb5633b954
3
+ size 232287788
boc_lite_partitioned/2017.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f0108f2596955e106cc0e09baca939ba5677379478b8346d608a716086ad5f4e
3
+ size 263386255
boc_lite_partitioned/2018.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:af74d3ebdf89f924eefe028b089cd87cc0f2944a046eac2c2da977945ae3e000
3
+ size 280577356
boc_lite_partitioned/2019.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba893fb4a7e2d1587d8306e59923e84ea06c56f18622106d23a034e5dfb03d88
3
+ size 286002866