This page is a standalone code guide. Copy each Python block to Google Colab and run it there.
Download CSV data through HTTP, validate the response, then convert the returned text into a pandas DataFrame.
requests.get()raise_for_status()response.textdf, which Step 2 uses.import requests
import pandas as pd
from io import StringIO
url = "https://raw.githubusercontent.com/cs109/2014_data/master/countries.csv"
response = requests.get(url, timeout=10)
response.raise_for_status()
print("HTTP:", response.status_code)
print("Content-Type:", response.headers.get("content-type"))
df = pd.read_csv(StringIO(response.text))
print(df.head())
print("Rows:", len(df))
# Continue from df created in Step 1
print("\nMissing values")
print(df.isna().sum())
print("\nCount by Region")
summary = (
df.groupby("Region")
.size()
.sort_values(ascending=False)
)
print(summary)
# Filter one region
europe = df[df["Region"] == "EUROPE"]
print("\nEurope rows:", len(europe))
print(europe.head())