library(reticulate)
## Warning: package 'reticulate' was built under R version 4.5.3
use_python("C:/ProgramData/Anaconda3/python.exe")
import os
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = 'C:/ProgramData/Anaconda3/Library/plugins/platforms'

Introduction of the Dataset This dataset analyzes the economic impact of war across different regions. By comparing these variables, the dataset helps highlight how war disrupts economic stability and affects everyday life in different regions. The data spans multiple years and regions, allowing for a broader view of patterns and differences in how economies respond to conflict. Overall, it provides a useful foundation for analyzing which regions are most affected and which economic indicators are most sensitive to war.

First Visualization: Unemployment Change by Region¶

import pandas as pd
import matplotlib.pyplot as plt

data = pd.read_csv("war_economic_impact_dataset.csv.csv")

data['Unemployment_Change'] = data['During_War_Unemployment_%'] - data['Pre_War_Unemployment_%']

viz1 = data.groupby('Region')['Unemployment_Change'].mean()
viz1.plot(kind='bar')

plt.title("Average Unemployment Change by Region During War")
plt.xlabel("Region")
plt.ylabel("Unemployment Change (%)")
plt.show()

Explanation of First Graph:

This graph shows how unemployment changed across different regions during war. Each bar represents a region, and the height shows how much unemployment increased. The Middle East stands out the most because the increase is way higher than everywhere else. This shows that war had a much bigger impact on jobs there compared to the other regions. The rest of the regions like Africa, East Asia, Europe, and South Asia all have pretty similar increases. They still go up, but not nearly as much as the Middle East. Overall, this shows that unemployment tends to rise during war in every region, but some areas get hit a lot harder than others.

Second Visualization: Dual-Axis Bar Chart

import numpy as np
data['Unemployment_Change'] = data['During_War_Unemployment_%'] - data['Pre_War_Unemployment_%']
region_count = data.groupby('Region')['Conflict_Name'].count()
avg_unemployment = data.groupby('Region')['Unemployment_Change'].mean()

import matplotlib.pyplot as plt
import numpy as np


data['Unemployment_Change'] = data['During_War_Unemployment_%'] - data['Pre_War_Unemployment_%']


region_count = data.groupby('Region')['Conflict_Name'].count()
avg_unemployment = data.groupby('Region')['Unemployment_Change'].mean()


regions = region_count.index
x = np.arange(len(regions))
width = 0.4

fig, ax1 = plt.subplots(figsize=(12,7))
ax2 = ax1.twinx()

ax1.bar(x - width/2, region_count, width=width, color='steelblue', label='Conflict Count')
ax2.bar(x + width/2, avg_unemployment, width=width, color='orange', label='Avg Unemployment Change')

ax1.set_xlabel('Region', fontsize=14)
ax1.set_ylabel('Number of Conflicts', fontsize=14)
ax2.set_ylabel('Average Unemployment Change (%)', fontsize=14)

ax1.set_xticks(x)
ax1.set_xticklabels(regions, rotation=45)

plt.title('Conflict Count and Average Unemployment Change by Region', fontsize=16)
plt.tight_layout()
plt.show()

Explanation of Graph 2:

This graph is a dual-axis chart that compares conflict count and average unemployment change for each region of the world. The graph shows that the Middle East was clearly affected the most with unemployment and the number of conflicts. It was interesting how closely correlated these two metrics are. The only wide spread that is visible is Asia as a whole.

Overall, this graph shows that when countries face higher unemployment, they are also more likely face different conflicts as well.

Third Visualization: Multi-Line Plot¶

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

data = pd.read_csv("war_economic_impact_dataset.csv.csv")
print(data.columns.tolist())
## ['Conflict_Name', 'Conflict_Type', 'Region', 'Start_Year', 'End_Year', 'Status', 'Primary_Country', 'Pre_War_Unemployment_%', 'During_War_Unemployment_%', 'Unemployment_Spike_Percentage_Points', 'Most_Affected_Sector', 'Youth_Unemployment_Change_%', 'Pre_War_Poverty_Rate_%', 'During_War_Poverty_Rate_%', 'Extreme_Poverty_Rate_%', 'Food_Insecurity_Rate_%', 'Households_Fallen_Into_Poverty_Estimate', 'GDP_Change_%', 'Inflation_Rate_%', 'Currency_Devaluation_%', 'Cost_of_War_USD', 'Estimated_Reconstruction_Cost_USD', 'Informal_Economy_Size_Pre_War_%', 'Informal_Economy_Size_During_War_%', 'Black_Market_Activity_Level', 'Primary_Black_Market_Goods', 'Currency_Black_Market_Rate_Gap_%', 'War_Profiteering_Documented']
data['Unemployment_Change'] = data['During_War_Unemployment_%'] - data['Pre_War_Unemployment_%']
region_summary = data.groupby('Region').agg({
    'Conflict_Name': 'count',
    'Unemployment_Change': 'mean',
    'Inflation_Rate_%': 'mean'
}).reset_index()

region_summary = region_summary.rename(columns={'Conflict_Name': 'Conflict_Count'})
region_summary = region_summary.sort_values(by='Conflict_Count', ascending=False).head(5)

print(region_summary)
##         Region  Conflict_Count  Unemployment_Change  Inflation_Rate_%
## 3  Middle East           45408            18.617816         69.995181
## 2       Europe           18225             9.451199         69.921274
## 0       Africa           18132             9.460761         69.881182
## 4   South Asia            9162             9.374072         69.867762
## 1    East Asia            9073             9.450406         69.957683
from sklearn.preprocessing import StandardScaler

region_means = data.groupby('Region')[['Unemployment_Change', 'Inflation_Rate_%', 'GDP_Change_%']].mean().reset_index()

top_regions = data['Region'].value_counts().head(5).index
region_means = region_means[region_means['Region'].isin(top_regions)]

scaler = StandardScaler()
scaled_values = scaler.fit_transform(region_means[['Unemployment_Change', 'Inflation_Rate_%', 'GDP_Change_%']])

scaled_df = pd.DataFrame(scaled_values, columns=['Unemployment_Change', 'Inflation_Rate_%', 'GDP_Change_%'])
scaled_df['Region'] = region_means['Region'].values


plt.figure(figsize=(12, 7))

plt.plot(scaled_df['Region'], scaled_df['Unemployment_Change'], marker='o', linewidth=2, label='Unemployment Change')
plt.plot(scaled_df['Region'], scaled_df['Inflation_Rate_%'], marker='s', linewidth=2, label='Inflation Rate')
plt.plot(scaled_df['Region'], scaled_df['GDP_Change_%'], marker='^', linewidth=2, label='GDP Change')

plt.xlabel('Region')
plt.ylabel('Standardized Value')
plt.title('Standardized Economic Indicators by Region')
plt.legend()
plt.tight_layout()
plt.show()

Explanation of Graph:

This graph shows how unemployment change, inflation, and GDP change compare across different regions. The values are standardized, so instead of showing exact numbers, it shows how each region compares relative to the others.It is important to show this when comparing different regions of the world.

The Middle East stands out the most because it has the highest unemployment increase and inflation, while also having the biggest drop in GDP. This suggests that this region was hit the hardest economically.

Other regions like East Asia and Europe look more stable, with smaller changes across all three indicators. Africa and South Asia are more mixed, showing some increases and decreases depending on the variable.

Overall, this graph shows that the economic impact of war is not the same everywhere, and some regions experience much more extreme effects than others.

Fourth Visualization: Waterfall Diagram

import pandas as pd
import plotly.graph_objects as go

data = pd.read_csv("war_economic_impact_dataset.csv.csv")
gdp_viz = data.groupby('Region')['GDP_Change_%'].mean().sort_values()

fig = go.Figure(go.Waterfall(
    name="GDP Change",
    orientation="v",
    measure=["relative"] * len(gdp_viz),
    x=gdp_viz.index,
    y=gdp_viz.values,
    text=[f"{v:.2f}%" for v in gdp_viz.values],
    textposition="outside"
))

fig.update_layout(
    title="Waterfall Chart of GDP Change by Region During War",
    xaxis_title="Region",
    yaxis_title="GDP Change (%)",
    showlegend=False
)
fig.show()

Explanation of Graph:

This waterfall chart illustrates the cumulative impact of war on GDP change across different regions. Each bar represents the percentage change in GDP for a specific region, and the downward progression shows that all regions experienced economic decline during periods of conflict.

The Middle East shows the largest initial decrease, followed by additional declines in South Asia, Africa, Europe, and East Asia. As each region is added, the total GDP becomes negative by a signifigant margin.

Overall, the chart emphasizes that conflict has a consistently negative effect on economic performance, with all regions contributing to a significant cumulative decline in GDP.

Fifth Visualization: Bump Chart

import pandas as pd
import matplotlib.pyplot as plt
variables = [
    'GDP_Change_%',
    'Inflation_Rate_%',
    'During_War_Poverty_Rate_%',
    'Unemployment_Spike_Percentage_Points'
]
label_names = {
    'GDP_Change_%': 'GDP Change',
    'Inflation_Rate_%': 'Inflation',
    'During_War_Poverty_Rate_%': 'Poverty Rate',
    'Unemployment_Spike_Percentage_Points': 'Unemployment Spike'
}


bump_df = data[['Start_Year'] + variables].copy()


bump_df = bump_df.groupby('Start_Year', as_index=False)[variables].mean()


for var in variables:
    min_val = bump_df[var].min()
    max_val = bump_df[var].max()
    if max_val != min_val:
        bump_df[var] = (bump_df[var] - min_val) / (max_val - min_val)
    else:
        bump_df[var] = 0


bump_df = bump_df.melt(
    id_vars='Start_Year',
    var_name='Variable',
    value_name='Normalized_Value'
)


bump_df['Rank'] = (
    bump_df.groupby('Start_Year')['Normalized_Value']
    .rank(ascending=False, method='first')
)


years = sorted(bump_df['Start_Year'].unique())
x_positions = list(range(len(years)))
year_to_x = {year: i for i, year in enumerate(years)}
bump_df['x_pos'] = bump_df['Start_Year'].map(year_to_x)


fig, ax = plt.subplots(figsize=(10, 6))

for var in variables:
    subset = bump_df[bump_df['Variable'] == var].sort_values('x_pos')
    ax.plot(
        subset['x_pos'],
        subset['Rank'],
        marker='o',
        markersize=6,
        linewidth=2.5,
        label=label_names[var]
    )


ax.invert_yaxis()

ax.set_xticks(x_positions)
ax.set_xticklabels(years, rotation=45, fontsize=9)
ax.set_yticks([1, 2, 3, 4])

ax.set_title('Bump Chart: Ranking of Economic Indicators Over Time', fontsize=14, pad=12)
ax.set_xlabel('Year', fontsize=11)
ax.set_ylabel('Rank', fontsize=11)


ax.grid(axis='y', linestyle='--', alpha=0.35)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)


ax.legend(
    title='Indicators',
    bbox_to_anchor=(1.02, 1),
    loc='upper left',
    frameon=False
)

plt.tight_layout()
plt.show()

Explanation of the Graph:

This bump chart shows how the relative rankings of key economic indicators changed over time. Each line represents one indicator, and its vertical position shows its rank in a given year, with rank 1 indicating the highest normalized value. Since the variables were measured on different scales, they were normalized before ranking so the comparison would be meaningful. The chart highlights shifts in the relative importance of indicators being GDP change,Inflation, Poverty rate, and Unemployment spike.

Conclusion:

This analysis shows that war has a clear impact on he economy. By looking at factors like unemployment, GDP, or inflation, it is true that conflict disrupts stability and everyday life. The charts also shows what areas of the world were being affected the most by war. The important lesson is how a country is able to build their economy back up after conflict, some countries better than others. The visualizations help highlight these differences and make it easier to understand patterns in the data. In general, unemployment tends to rise, economic growth slows down, and financial conditions become more unstable during times of war. This dataset provides a useful way to see how these effects vary globally and emphasizes the broader economic consequences of conflict.