1. Concepts & Definitions
1.1. Experiment, observation, and sample space
1.2. Sample space: Venn and Tree diagram
1.3. Simple and composite events
1.4. Three definitions of probability
1.5. Law of large numbers and its consequences
1.6. Frequency and empirical probability
2. Problem & Solution
2.4. Frequency of categories from tables
2.5. Simple and marginal probabilities
2.6. Conditional probabilities
The following steps will serve as a guideline to create a six-face dice simulator in Python programming language:
Load the notebook with commands developed in step 2.2. (click on the link):
https://colab.research.google.com/drive/1mUX_ItyQzRGUC3qqjjCijTFzOW4TCIdL?usp=sharing
Let's check what are the products categories employed in customs using WITS database. First, it is necessary to install WITS API:
!pip install world_trade_data --upgrade
The following values will be stored in variable coin_seq:
Collecting world_trade_data Downloading world_trade_data-0.1.1.tar.gz (11 kB) Preparing metadata (setup.py) ... done
...Successfully built world_trade_data Installing collected packages: xmltodict, world_trade_data Successfully installed world_trade_data-0.1.1 xmltodict-0.13.0
The next sequences of commands are useful to obtain iso3Code and the name for each country:
import pandas as pd
import world_trade_data as wits
pd.set_option('display.max_rows', 6)
df_countries = wits.get_countries()
df_countries = df_countries.reset_index()
df_countries
The following table with values will appear:
Obtain the exportation values of Brazil (BRA) to all countries (ALL) in a table format:
bra_exports_2020 = wits.get_indicator('XPRT-TRD-VL', partner='all', reporter='bra', year='2020')
bra_exports_2020 = bra_exports_2020.reset_index()
bra_exports_2020
Obtain the exportation values of Brazil (BRA) aggregated per values of 'ProductCode' column:
bra_exports_2020_grouped_per_product = bra_exports_2020.groupby('ProductCode').aggregate({'Value':'sum'}).reset_index(drop=False)
bra_exports_2020_grouped_per_product
Obtain the first six greatest values in column 'Value' using aggregated values in 'ProductCode' column:
bra_exports_2020_grouped_per_product = bra_exports_2020_grouped_per_product.sort_values(by='Value', ascending=False)
bra_exports_2020_grouped_per_product.head(6)
The previous tables give insights to select certain categories of products according to their 'ProductCode'. In fact, there is a system called Harmony System (HS) Code which can be useful. More about HS code is explained in:
https://www.trade.gov/harmonized-system-hs-codes
https://icecargo.com.au/hs-codes-beginners-guide/
https://customs.gov.tl/doing-business/hs-code-tariff-and-incoterms/
The Python code with all the steps is summarized in this Google Colab (click on the link):
https://colab.research.google.com/drive/1mUX_ItyQzRGUC3qqjjCijTFzOW4TCIdL?usp=sharing