Skip to content

BW #139: Chinese exports

Get better at: Working with multiple Excel files, filtering, regular expressions, multi-indexes, window functions, styling, and plotting with Plotly.

BW #139: Chinese exports

[Note: We'll be holding Pandas office hours this coming Sunday at 17:00 in Israel, aka 10 a.m. Eastern. On Friday, I'll send full Zoom info to paid subscribers. Come with any and all Pandas questions!]

One of the key parts of Donald Trump's second term as president has been his enthusiastic use of tariffs to punish foreign nations. Trump has applied tariffs to all countries, but some have been hit particularly hard. India has been hit with high tariffs because it is importing Russian oil. Brazil has been hit with high tariffs because former president Jair Bolsonaro was convicted of trying to overthrow a democratic election. (It should be noted that despite what Trump claims, the exporting country doesn't pay the tariff, but rather the importer, who typically passes at least some of that cost along to the consumer.)

The one country that Trump mentions most frequently regarding tariffs, however, is China. This is largely because China exports so many goods to the United States, goods that Trump believes should be manufactured in the United States. He argues that by imposing tariffs on Chinese goods, more items will be made in the US, both boosting the US economy and weakening the Chinese economy.

There are at least three problems with this: First, while China used to be known for cheap and low-wage manufacturing, they are now the world's experts in a variety of design and manufacturing technologies. This means that it would be difficult, if not impossible, for the US to replace Chinese factories without a huge investment in research and development – just the opposite of what the Trump administration has done.

Second, China exports far more to the US than it imports. But it does import some things, particularly agricultural products such as soybeans. US farmers are currently unable to export to China, and are losing a great deal of income (https://www.msn.com/en-us/news/other/soybean-farmer-who-backed-trump-feels-strain-of-china-s-boycott-amid-trade-war/ar-AA1O2T54.)

Finally, while the United States is the world's largest economy, it's not the only market to which China can export. An article in a recent edition of the Economist indicated that while the US is importing less from China than it used to, China has more than made up for this change by exporting to other countries (https://www.economist.com/finance-and-economics/2025/09/09/chinese-trade-is-thriving-despite-americas-attacks?giftId=1d26bcbb-40c2-407c-8079-9071ee03068e&utm_campaign=gifted_article).This week, we'll look at Chinese government statistics from the last three years. Is trade between China and the United States declining? What countries are importing more from China than they used to, and which are importing less? And do any countries have a trade surplus with China?

Data and five questions

This week's data comes from the China Customs official Web site, where they post a variety of monthly reports, at http://english.customs.gov.cn/statics/report/monthly.html . Because the most recent data for 2025 is from August, and because I want to look at trade on a country-by-country basis, I want you to download the Excel files for August 2025, 2024, and 2023. These are available by choosing each year, selecting "Imports and Exports by Country(Region)of Origin/Destination," and downloading the file via the link at the bottom of the page.

Learning goals for this week are reading from multiple Excel files, filtering, regular expressions, multi-indexes, window functions, styling, and plotting with Plotly.

Paid subscribers to Bamboo Weekly, including subscribers to my LernerPython membership platform, can download the data files via a link at the bottom of this message. Paid members also see all questions and answers (not just the first two), are invited to monthly office hours, can download the notebook I use to solve each week's problems, and have one-click access to explore the notebook in the browser.

Here are my five questions and tasks for this week; I'll be back tomorrow with my solutions and explanations: