https://github.com/pradip-data/world-merchandise-trade
This project analyzes global merchandise trade trends from 1948 to 2023 using Google BigQuery and Python. It includes country-wise and product-wise trade performance, covering exports, imports, total trade, and trade deficit. The analysis features SQL queries for BigQuery, data visualizations, and detailed reports to uncover long-term trade pattern
https://github.com/pradip-data/world-merchandise-trade
datawarehouse google-biquery google-cloud-platform merchandise python python-visualization sql trade trade-data-1948-2023
Last synced: 21 days ago
JSON representation
This project analyzes global merchandise trade trends from 1948 to 2023 using Google BigQuery and Python. It includes country-wise and product-wise trade performance, covering exports, imports, total trade, and trade deficit. The analysis features SQL queries for BigQuery, data visualizations, and detailed reports to uncover long-term trade pattern
- Host: GitHub
- URL: https://github.com/pradip-data/world-merchandise-trade
- Owner: pradip-data
- Created: 2025-03-01T16:34:43.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-04T09:54:19.000Z (over 1 year ago)
- Last Synced: 2025-08-10T16:34:02.360Z (10 months ago)
- Topics: datawarehouse, google-biquery, google-cloud-platform, merchandise, python, python-visualization, sql, trade, trade-data-1948-2023
- Language: Jupyter Notebook
- Homepage:
- Size: 30.2 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ๐ Global Merchandise Trade (1947-2023) Analysis using ChatGPT AI, Google BigQuery & Python
## ๐ Project Overview
This project analyzes **global merchandise trade trends from 1947 to 2023**, with a primary focus on **India's trade performance**. The dataset is sourced from **Google BigQuery** and consists of key indicators such as **exports, imports, total trade, and trade deficit** for different countries. The analysis leverages:
### ๐ Technologies & Methodologies Used:
โ
**Google BigQuery** โ Efficient data extraction & querying ๐
โ
**Python** โ Data processing, transformation & visualization ๐
โ
**ChatGPT AI** โ AI-driven insights & trend analysis ๐ค
โ
**Automated PDF Reports** โ Structured storytelling with key findings ๐
---
## ๐ Data Source
๐ The trade data used in this project is sourced from the **World Trade Organization (WTO)**.
๐ **Official WTO Merchandise Trade Statistics:** [WTO Trade Data](https://www.wto.org/english/res_e/statis_e/merch_trade_stat_e.htm)
---
## ๐ Key Objectives
๐น Analyze **India's exports, imports, total trade, and trade deficit** over time.
๐น Compare **India's trade performance** against **global leaders**.
๐น Identify **key trade trends, challenges, and opportunities** for improvement.
---
## ๐ Key Questions Analyzed
1๏ธโฃ **How has global trade evolved from 1947 to 2023?**
2๏ธโฃ **What is Indiaโs trade performance in exports, imports, and total trade?**
3๏ธโฃ **How has Indiaโs trade deficit changed over time?**
4๏ธโฃ **How does India compare with top exporting and importing nations?**
5๏ธโฃ **What are the key challenges in Indiaโs trade landscape?**
6๏ธโฃ **What strategies can improve Indiaโs trade competitiveness?**
---
## ๐ Dataset Overview
### ๐ Dataset Structure
| Column Name | Description |
|--------------------|------------------------------------|
| **IndicatorCode** | Unique code for trade indicators |
| **Indicator** | Type of trade (Exports/Imports) |
| **ReporterCountry** | Country reporting the trade |
| **Partner** | Trade partner country |
| **ProductCode** | Unique product identifier |
| **Product** | Name of traded product |
| **Year** | Trade year |
| **Value_MillionUSD** | Trade value in million USD |
---
## ๐ฅ Installation
### ๐ Clone the Repository
```bash
git clone https://github.com/yourusername/Global-Trade-Analysis.git
cd Global-Trade-Analysis
```
### ๐ฆ Install Dependencies
```bash
pip install pandas matplotlib seaborn fpdf google-cloud-bigquery
```
### ๐ Set Up Google BigQuery Credentials
1๏ธโฃ Create a **Google Cloud Project**.
2๏ธโฃ Enable **BigQuery API**.
3๏ธโฃ Download your **service account JSON key** and set it as an environment variable:
```bash
export GOOGLE_APPLICATION_CREDENTIALS="path/to/your-key.json"
```
---
## ๐ Analysis & Code Overview
## ๐ Section A : Some BigQuery Code & Console Screenshots
### 1๏ธโฃ Yearly Growth of Trade Value (1948-2023)
```sql
WITH YearlyTrade AS (
SELECT
Year,
SUM(Value_MillionUSD) AS Trade_Value
FROM `my-project-1711648161671.World_Trade.Countries_Merchandise_Trade`
WHERE Product="Total merchandise"
GROUP BY Year
)
SELECT
Year,
Trade_Value,
LAG(Trade_Value) OVER (ORDER BY Year) AS Prev_Year_Trade_Value,
ROUND(((Trade_Value - LAG(Trade_Value) OVER (ORDER BY Year)) / LAG(Trade_Value) OVER (ORDER BY Year)) * 100, 2) AS Growth_Percentage
FROM YearlyTrade
ORDER BY Year;
```
### 2๏ธโฃ India's Total Trade Value (Exports + Imports) (1948-2023)
```sql
SELECT
Year,
SUM(Value_MillionUSD) AS Total_Trade_Value
FROM `my-project-1711648161671.World_Trade.Countries_Merchandise_Trade`
WHERE ReporterCountry = 'India' AND Product ="Total merchandise"
GROUP BY Year
ORDER BY Year;
```
### 3๏ธโฃ India's Trade Deficit (1948-2023)
```sql
WITH IndiaTrade AS (
SELECT
Year,
SUM(CASE WHEN Indicator = 'exports' THEN Value_MillionUSD ELSE 0 END) AS India_Exports,
SUM(CASE WHEN Indicator = 'imports' THEN Value_MillionUSD ELSE 0 END) AS India_Imports
FROM `my-project-1711648161671.World_Trade.Countries_Merchandise_Trade`
WHERE ReporterCountry = 'India' AND Product ="Total merchandise"
GROUP BY Year
)
SELECT
Year,
India_Exports,
India_Imports,
(India_Imports - India_Exports) AS Trade_Deficit,
CASE
WHEN (India_Imports - India_Exports) > 0 THEN 'Trade Deficit'
ELSE 'Trade Surplus'
END AS Trade_Status
FROM IndiaTrade
ORDER BY Year;
```
## ๐ธ BigQuery Execution Screenshots


---
## ๐ Section B : Python Code & Visualizations
### ๐ Python Code for Data Visualization
```python
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from reportlab.lib.pagesizes import letter
from reportlab.pdfgen import canvas
# ๐ Load dataset
file_path = r"C:\Users\chemi\Downloads\PROJECT -World Merchandise Trade (Bigquery Project)\BigQuery Output Result\India's Global Trade Case Study (1948-2023).csv"
df = pd.read_csv(file_path)
# ๐ Data Preprocessing
df['Year'] = pd.to_numeric(df['Year'], errors='coerce')
df["Trade Balance"] = df["India_Exports"] - df["India_Imports"]
df["Total Trade"] = df["India_Exports"] + df["India_Imports"]
# ๐ฅ 1. India's Exports & Imports Over Time
plt.figure(figsize=(12, 6))
sns.lineplot(x="Year", y="India_Exports", data=df, label="Exports", marker="o", color="blue")
sns.lineplot(x="Year", y="India_Imports", data=df, label="Imports", marker="s", color="red")
plt.title("India's Exports & Imports (1948-2023)")
plt.xlabel("Year")
plt.ylabel("USD Billion")
plt.legend()
plt.grid(True)
plt.show()
```
## ๐ธ Generated Visualizations
### 1. Export & Import Growth Trend (2013-2023)
.png)
### 2. India's Imports & Exports Trend (1948-2023)
.png)
### 3. India's Trade Breakdown 2023

### 4. India's Share in Global Trade over Time

### 5. Top 10 Countries with Highest Trade Deficit

### 6. India's Position in Trade 2023

### 7. Trade Deficit Comparison between India and China (2023)

---
## ๐ Section C : AI-Generated Reports
### ๐ 1. Detailed Insights, Observations, and Recommendations on India's Trade Performance (2023)
๐ **Comprehensive analysis** covering key insights, trends, and expert recommendations for India's trade performance in 2023.
๐ **[View Report](https://github.com/pradip-data/World-Merchandise-Trade/blob/4ab61b1a611682941040f6f859c2f8a83a4d19aa/AI%20Generated%20Insights%20%26%20Recommendation/Detailed%20Insights%2C%20Observations%2C%20and%20Recommendations%20on%20India%E2%80%99s%20Trade%20Performance%20(2023).pdf)**
---
### ๐ 2. India's Product-wise Trade Performance (1948-2023)
๐ **In-depth report** analyzing India's product-wise trade trends from 1948 to 2023, highlighting key patterns and growth opportunities.
๐ **[View Report](https://github.com/pradip-data/World-Merchandise-Trade/blob/8ba22ef6284438ed8727f88f5664873bc7a6b704/AI%20Generated%20Insights%20%26%20Recommendation/Insights-India's%20Product-wise%20Trade%20Performance%20(1948-2023)%20detailed.pdf)**
---
# ๐ India's Trade Performance Analysis (2023) ๐
## ๐ Insights: India's Trade Performance in 2023
- **Exports:** ๐ฐ $431,574 Million USD
- **India's Export Percentage:** ๐ 1.81%
- **Export Rank:** ๐ 17
- **Imports:** ๐ฐ $672,231 Million USD
- **India's Import Percentage:** ๐ 2.77%
- **Import Rank:** ๐ 8
- **Total Trade:** ๐ฐ $1,103,805 Million USD
- **India's Total Trade Percentage:** ๐ 2.3%
- **Trade Rank:** ๐ 14
- **Trade Deficit:** โ $240,657 Million USD
India remains one of the largest players in global trade. In 2023, India's exports crossed **$431,574 million**, placing it among the **top exporters** worldwide. However, its **imports outpaced exports**, leading to a **significant trade deficit**. India continues to be a major importer of **crude oil, gold, and electronic components**, while its key export sectors include **pharmaceuticals, IT services, and textiles**. The trade balance has been influenced by **global economic conditions, currency fluctuations, and demand shifts** in international markets.
---
## ๐ Top Exporting Countries & Rankings (2023)
- 1๏ธโฃ **China** - $3,379,255M
- 2๏ธโฃ **United States** - $2,020,606M
- 3๏ธโฃ **Germany** - $1,718,251M
- 4๏ธโฃ **Netherlands** - $936,392M
- 5๏ธโฃ **Japan** - $717,261M
- 6๏ธโฃ **Italy** - $676,993M
- 7๏ธโฃ **France** - $648,569M
- 8๏ธโฃ **South Korea** - $632,226M
- 9๏ธโฃ **Mexico** - $593,005M
- ๐ **Hong Kong** - $573,871M
---
## ๐ Top Importing Countries & Rankings (2023)
- 1๏ธโฃ **United States** - $3,172,476M
- 2๏ธโฃ **China** - $2,556,565M
- 3๏ธโฃ **Germany** - $1,476,656M
- 4๏ธโฃ **Netherlands** - $842,331M
- 5๏ธโฃ **United Kingdom** - $791,523M
- 6๏ธโฃ **France** - $786,158M
- 7๏ธโฃ **Japan** - $785,796M
- 8๏ธโฃ **India** - $672,231M
- 9๏ธโฃ **Hong Kong** - $653,696M
- ๐ **South Korea** - $642,572M
---
## ๐ฐ Countries with the Highest Trade Surpluses (2023)
๐น **China** - $822,690M
๐น **Germany** - $241,595M
๐น **Russia** - $120,925M
๐น **Saudi Arabia** - $113,078M
๐น **Netherlands** - $94,061M
---
## ๐ด Countries with the Highest Trade Deficits (2023)
โ **United States** - $1,151,870M
โ **United Kingdom** - $270,483M
โ **India** - $240,657M
โ **France** - $137,589M
โ **Tรผrkiye** - $106,327M
---
## โ ๏ธ Key Challenges Identified
- 1๏ธโฃ **High Import Dependency** ๐ญ: India imports more than it exports in key categories like **fuels, machinery, and pharmaceuticals**, leading to a trade imbalance.
- 2๏ธโฃ **Weak Export Competitiveness** ๐: India's **export share (1.81%)** is much lower than its economic size, indicating **low global competitiveness**.
- 3๏ธโฃ **Sector-Specific Deficits** ๐ฅ: Deficits in **pharmaceuticals and food sectors** suggest a **need for domestic production growth and export incentives**.
- 4๏ธโฃ **Limited Market Penetration** ๐: India relies **heavily on traditional export markets**, limiting its trade reach.
---
## ๐ฏ Strategic Recommendations & Policy Suggestions
### A. ๐ Boosting Exports
โ
**Expand High-Value Manufacturing** ๐ง
- Encourage **semiconductor, AI, and high-tech industries**
- Invest in **automobile and electronics manufacturing**
โ
**Strengthen Trade Agreements** ๐ค
- Negotiate **preferential trade deals** with **Africa, Latin America, and Southeast Asia**
โ
**Enhance Export Incentives** ๐
- Introduce **tax benefits for export-driven industries**
### B. ๐ Reducing Import Dependence
โ
**Increase Domestic Production in Deficit Sectors** ๐ญ
- Expand **pharmaceutical manufacturing** to reduce **$17.9B deficit**
- Boost **agriculture and textile production** to cut food & clothing imports
โ
**Invest in Renewable Energy** โ๏ธ
- Reduce **oil import dependency ($220.6B)** by investing in **solar, wind, and green hydrogen**
### C. ๐ข Strengthening Trade Infrastructure
โ
**Improve Logistics & Ports** โ
- Reduce **trade costs and shipment delays** to make exports more competitive
โ
**Ease Business Regulations** ๐
- Simplify **tax laws and streamline customs processes** for exporters
### D. ๐ Diversifying Export Markets
โ
**Expand Beyond Traditional Markets** ๐
- Strengthen trade with **Africa, Middle East, and Latin America**
- Reduce **over-reliance on US and European markets**
---
## ๐ฎ Final Outlook
India has the **potential to become a major global trade powerhouse** but must address **its trade deficit, boost exports, and reduce import dependence**. By implementing **strategic manufacturing policies, improving infrastructure, and diversifying export markets**, India can move **up in global trade rankings** and achieve a **more balanced trade profile** in the coming years.
### ๐ฏ Key Focus Areas for 2024 & Beyond
- โ
Strengthen **high-value manufacturing exports**
- โ
Reduce **fuel & machinery import dependency**
- โ
Improve **trade policies and agreements**
- โ
Expand **global market reach beyond traditional partners**
- โ
Invest in **logistics and supply chain efficiency** ๐ข
---
### ๐ BigQuery Analysis & Python Visualizations
๐ **BigQuery SQL Code & Execution Screenshots**
๐ **Python Code for Trade Analysis & Data Visualization**
๐ **ChatGPT AI Report Generation & Insights**
## ๐ Final Thoughts
India has the potential to become a **major global trade powerhouse** but must address:
๐ **Trade Deficit Challenges** โ Reduce reliance on imports.
๐ **Boost Export Competitiveness** โ Focus on high-value industries.
๐ **Expand Market Reach** โ Diversify beyond traditional partners.
By implementing **strategic policies**, **investing in infrastructure**, and **expanding global trade agreements**, India can significantly improve its trade rankings and achieve a **balanced trade profile** in the coming years.
---
๐ Author & Contributions
๐ค Your Name - Mangroliya Pradip
๐ฉ For inquiries, reach out at: pradipias2023@gmail.com
---