张春成

V2

2022/11/21阅读:39主题:默认主题

World trade data

从贸易伙伴的观点看国际贸易

The analysis script and data are provided in

https://github.com/listenzcc/World-trade-data-I

Two opinions raise by the analysis

  • Every country trade with limited other countries. And there are not any country expanding to every other country.
  • The world has only little countries that dominate the international trading.

要形成自己的观点和方法论就不能太信任似是而非的经验, 所以要自己睁眼看看。

本文对国际贸易进行数据收集与分析,初步得到两个观点,数据、代码和可视化代码可见我的 Github 代码库。

  • 每个国家都与有限的其他国家进行贸易,没有任何一个国家能够扩张到全部其他国家,

    如果按照排名前 5 名的贸易伙伴来说,一个国家的全部伙伴的伙伴都加在一起,他们的数量也会小于 30。

  • 世界上只有少数几个国家主宰着国际贸易,

    如果把国家与国家之间的贸易伙伴数量列一个矩阵,那么这个矩阵会相当稀疏。

其余的懒得写成中文了,因为 markdown 写中文写太麻烦,好在配图可以说明一些事情。


I collect the data from wits. The full name of the website is World Integrated Trade Solution, and it is a quite useful data website.

WITS
WITS

WITS

Trading partnership

Specifically, the data of trading partnership across countries is collected from the website, and I place them in the folder of witsen_trade_summary.

In every .csv files, trading partnership of the country is provided. I am interested in the records being named as:

  • ‘Trade (US$ Mil)-Top 5 Export Partner’
  • ‘Trade (US$ Mil)-Top 5 Import Partner’

The meaning is the top 5 partnership countries, in the trading relationship as Export or Import. And the unit is a million US dollar.

I use the IPython notebook to process the data, (see the readme.ipynb), and it produces the sorted data as following dataframe

Export
Export

Export

Import
Import

Import

Trading partnership in Sankey Diagram

Based on the dataframe, I compute the international trading partnership, and display them with Sankey Diagram.

Sankey
Sankey

Sankey

The water-flow width represent the volume of the trading, and the linked nodes represent the country, the node colors represent the importance level of the partner country. And the importance level of the partner country is determined by the searching results.

Search
Search

Search

I believe it is self explained. Here is how the Sankey diagram is constructed. I just walk through the dataframe starting with the root node, take “China” for example. The travel moves into the partners iteratively, and records every country it passes through. When a target country is visited, the ‘chain’ links the root and target countries is also recorded. Moreover, the earlier the country is visited, the more important I believe it is, and the level is thus smaller.

I have also built a dash app to view the results in UI mode. You can play with it by yourself.

cd dash
python app.py
dash-china.png
dash-china.png
china-usa.png
china-usa.png

The very thing shocks me a lot is the small lines of the table. So far as I can see, there are not any countries that expand to partnerships more than 30. Thus, I reach my first opinion

Every country trade with limited other countries. And there are not any country expanding to every other country.

Important country

My next question raises,

Is there any country significant?

To answer the question, I play the Sankey analysis for every country, and produce the degree map for the countries

degree-map
degree-map

degree-map

The degrees represent the times of the country being visited. The degree1 is the times as the source country, and the degree2 is the times as the target country, and the degree is the sum of degree1 and degree2.

Degree map

The degrees are shown below. I consider it as the importance metric of countries, the significant countries are Germany, United States, China, Korea. Rep, India, Hong Kong. China, United Arab Emirates, France, Japan, Singapore, Mexico, Russian Federation ….

degree-bar-graph
degree-bar-graph

degree-bar-graph

Partnership map

Moreover, I also analysis the links between countries. The links between countries are computed for every two countries, the values are the times of being the trading partnership between the two countries. The links are shown in the sparse matrix, and the values in the graph are in logarithmic.

links
links

links

It is interactive graph, put your mouse on the colored nodes, it will show the relationship between the two countries. For example, in the import part, the most left vertical line represents China. The 1.3424 refers to

links-china
links-china

links-china

So, I reach to my second opinion,

The world has only little countries that dominate the international trading.

分类:

其他

标签:

金融

作者介绍

张春成
V2