The purpose of this notebook is to explore the miliary data from data.world. I'm mostly interested in the size of the military relative to the country, or active members per capita.
import plotly_express as px
df = pd.read_csv('C:/Users/willk/Downloads/Military Data .csv')
df.info()
<class 'pandas.core.frame.DataFrame'> RangeIndex: 172 entries, 0 to 171 Data columns (total 8 columns): Country 172 non-null object Active military 171 non-null object Reserve military 171 non-null object Paramilitary 171 non-null object Total 172 non-null object Per 1000 capita (total) 172 non-null float64 Per 1000 capita (active) 171 non-null float64 Unnamed: 7 0 non-null float64 dtypes: float64(3), object(5) memory usage: 10.8+ KB
df.columns = ['country', 'active', 'reserve', 'para', 'total',
'total_per_1000', 'active_per_1000', 'unknown']
df = df.drop(columns=['unknown'])
df.to_csv('military_data.csv')
df.head()
country | active | reserve | para | total | total_per_1000 | active_per_1000 | |
---|---|---|---|---|---|---|---|
0 | Afghanistan | 171,200 | 0 | 148,200 | 319,400 | 9.6 | 5.1 |
1 | Albania | 8,000 | 0 | 500 | 8,500 | 2.8 | 2.6 |
2 | Algeria | 130,000 | 150,000 | 187,200 | 467,200 | 11.6 | 3.2 |
3 | Angola | 107,000 | 0 | 10,000 | 117,000 | 5.8 | 5.3 |
4 | Antigua and Barbuda | 180 | 80 | 0 | 260 | 2.8 | 1.9 |
px.scatter(df, 'active', 'active_per_1000',
hover_name='country')
px.scatter(df, 'total', 'total_per_1000', hover_name='country')
px.scatter_geo()
df.columns = ['country', 'active', ]
px.scatter(df, 'Active military', 'Per 1000 capita (active)')
Import libraries and write settings here.
# Data manipulation
import pandas as pd
import numpy as np
# Options for pandas
pd.options.display.max_columns = 50
pd.options.display.max_rows = 30
# Display all cell outputs
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = 'all'
from IPython import get_ipython
ipython = get_ipython()
# autoreload extension
if 'autoreload' not in ipython.extension_manager.loaded:
%load_ext autoreload
%autoreload 2
# Visualizations
import plotly.plotly as py
import plotly.graph_objs as go
from plotly.offline import iplot, init_notebook_mode
init_notebook_mode(connected=True)
import cufflinks as cf
cf.go_offline(connected=True)
cf.set_config_file(theme='white')
Do work here
Show graphs and stats here
Summarize findings here