This project demonstrates how to fetch, clean, and analyze real-world economic data directly from the web using Python. Web Scraping GDP Data using Python and Pandas
This project demonstrates how to fetch, clean, and analyze real-world economic data directly from the web using Python.
import numpy as np import pandas as pd import requests def warn(*args, **kwargs): pass import warnings warnings.warn = warn warnings.filterwarnings('ignore') URL="https://web.archive.org/web/20230902185326/https://en.wikipedia.org/wiki/List_of_countries_by_GDP_%28nominal%29" response = requests.get(URL, verify=False) tables = pd.read_html(response.text) df = tables[3] df.columns = range(df.shape[1]) df = df.iloc[:, [0, 1]] # select both columns df.columns = ['Country','GDP(Million USD)'] df Output
A clean and structured DataFrame showing the list of countries and their nominal GDP values (in millions of USD).
π§° Tools & Libraries
pandas β For data extraction and transformation
requests β For retrieving web page content
numpy β For numerical operations
warnings β To suppress unneeded runtime warnings
π Concepts Practiced
Web scraping using pandas.read_html()
DataFrame slicing with .iloc
Column renaming and structuring
Clean data pipeline for analysis or visualization