International Trade Data#
Tools for working with the international trade dataset from the Harvard Growth Lab.
- hiveplotlib.datasets.international_trade.international_trade_data(year: int = 2019, hs92_code: int = 8112, path: str | Path | None = None) Tuple[DataFrame, Dict]#
Read in international trade data network from the Harvard Growth Lab.
Note
Only a limited number of subsets of the data are shipped with
hiveplotlib, as each year of trade data is roughly 300mb. However, the raw data are available at the Harvard Growth Lab’s website, and the runner to produce the necessary files to use this reader function is available in the repository (make_trade_network_dataset.py).If you are using the runner to make your own trade datasets that you will read in locally with this function, then you will need to specify the local
pathaccordingly.- Parameters:
year – which year of data to pull. If the year of data is not available, an error will be raised.
hs92_code – which HS 92 code of export data to pull. If the code requested is not available, an error will be raised. There are different numbers of digits (e.g. 2, 4), where more digits leads to more specificity of trade group. For a reference to what trade groups these codes correspond to, see this resource.
path – directory containing both the data and metadata for loading. Default
Noneassumes you are using one of the datasets shipped withhiveplotlib. If you are using themake_trade_network_dataset.pyrunner discussed above to make your own datasets, then you will need to specify the path to the directory where you saved both the data and metadata files (which must be in the same directory).
- Returns:
pandas.DataFrameof trade data, dictionary of metadata explaining meaning of data’s columns, data provenance, citations, etc.- Raises:
AssertionErrorif the requested files cannot be found.