Skip to content

Global Terrorism Database Analysis

Goal

Use GTD-like incident data to:

  • Visualize incidents over time
  • Compare regions
  • Identify major trend changes

Important note

This is a sensitive dataset. Focus on high-level aggregated analysis and avoid sensationalizing.

Analysis pipeline

diagram GTD trend analysis pipeline mermaid
From raw incident records to a responsible, aggregated summary.

Step 1: Load

Load
import pandas as pd
 
df = pd.read_csv("data/gtd.csv")
print(df.head())
Load
import pandas as pd
 
df = pd.read_csv("data/gtd.csv")
print(df.head())

Step 2: Incidents by year

Incidents per year
import matplotlib.pyplot as plt
 
yearly = df.groupby("year").size()
 
plt.figure(figsize=(10, 4))
plt.plot(yearly.index, yearly.values)
plt.title("Incidents by year")
plt.xlabel("Year")
plt.ylabel("Count")
plt.tight_layout()
plt.show()
Incidents per year
import matplotlib.pyplot as plt
 
yearly = df.groupby("year").size()
 
plt.figure(figsize=(10, 4))
plt.plot(yearly.index, yearly.values)
plt.title("Incidents by year")
plt.xlabel("Year")
plt.ylabel("Count")
plt.tight_layout()
plt.show()

Step 3: Compare regions

Top regions
import seaborn as sns
import matplotlib.pyplot as plt
 
regions = df["region"].value_counts().head(10).reset_index()
regions.columns = ["region", "count"]
 
plt.figure(figsize=(10, 4))
sns.barplot(data=regions, x="count", y="region")
plt.title("Top regions by incident count")
plt.tight_layout()
plt.show()
Top regions
import seaborn as sns
import matplotlib.pyplot as plt
 
regions = df["region"].value_counts().head(10).reset_index()
regions.columns = ["region", "count"]
 
plt.figure(figsize=(10, 4))
sns.barplot(data=regions, x="count", y="region")
plt.title("Top regions by incident count")
plt.tight_layout()
plt.show()

Visualize it

sketch Incidents by year p5.js
A single amber line shows the overall trend across years; annotate any sharp turns.

Deliverable

  • Overall trend
  • Top regions by incidents
  • Notes about missingness/reporting bias

🧪 Try It Yourself

Exercise 1 – Incidents per year

Exercise 2 – Top regions by incident count

Exercise 3 – Bucket missing region as “Unknown”

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did