This JupyterLab
notebook is soley for exploring GeoPandas
using the builtin data: naturalearth_lowres
.
First let's load the necessary modules and data.
# first let's get the libs
import geopandas
# get the earth data
earth_lr = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
# see whats in the data
earth_lr
# let's see what unique continents are present
CONTINENTS_SET = set(earth_lr['continent'].values)
# remove some data
CONTINENTS_SET.remove('Seven seas (open ocean)')
We will begin exploring this data by looking at the pop_est
column.
# first let's look at the entire world's populations
earth_lr.plot('pop_est',
legend=True,
legend_kwds={'label': "Population by Country",
'orientation': "horizontal"},
figsize=(16, 16));
# next plot all continent Population Estimates separately
for continent in CONTINENTS_SET:
# plot
earth_lr[earth_lr['continent'] == continent].plot('pop_est',
figsize=(16, 12),
legend=True,
legend_kwds={'label': "Population by Country",
'orientation': "horizontal"});
Next we will be looking at the gdp_md_est
column.
# first let's look at the entire world's gdp
earth_lr.plot('gdp_md_est',
figsize=(16, 16),
legend=True,
legend_kwds={'label': "GDP by Country",
'orientation': "horizontal"});
# plot all continent GDP Estimates
for continent in CONTINENTS_SET:
# plot
earth_lr[earth_lr['continent'] == continent].plot('gdp_md_est',
figsize=(16, 12),
legend=True,
legend_kwds={'label': "GDP by Country",
'orientation': "horizontal"});
Finally we will calculate per capita GDP by finding the ration of: $$ \frac{GDP}{Population} $$
# calc per capita gdp
earth_lr['per_capita_gdp'] = earth_lr['gdp_md_est'] / earth_lr['pop_est']
# first let's look at the entire world's per capita gdp
earth_lr.plot('per_capita_gdp',
legend=True,
figsize=(16, 16),
legend_kwds={'label': "Per Capita GDP by Country",
'orientation': "horizontal"});
# plot all continent Population Estimates
for continent in CONTINENTS_SET:
# plot
earth_lr[earth_lr['continent'] == continent].plot('per_capita_gdp',
figsize=(16, 12),
legend=True,
legend_kwds={'label': "Per Capita GDP by Country",
'orientation': "horizontal"});